summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-06-28 17:18:21 -0700
committerGitHub <noreply@github.com>2024-06-28 17:18:21 -0700
commitbc8a0e6e68547cf07a246b8b6c886de155dc8282 (patch)
treea3540b01218c4674c399eb770c0f08e5ba594793 /cli/worker.rs
parent2ddae872f956ddd84656a302aa5f6b752f6a6ab5 (diff)
refactor(cli): Create wrapper around `deno_lockfile::Lockfile` (#24366)
As suggested in https://github.com/denoland/deno/pull/24355#discussion_r1657875422. I wasn't able to hide the mutex stuff as much as I'd like (ended up just adding an escape hatch `inner()` method that locks the inner mutex), because you can't return references to the inner fields through a mutex. This is mostly motivated by the frozen lockfile changes
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index 420d92c02..00a20ab4d 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -10,7 +10,6 @@ use deno_config::package_json::PackageJsonDeps;
use deno_core::anyhow::bail;
use deno_core::error::AnyError;
use deno_core::futures::FutureExt;
-use deno_core::parking_lot::Mutex;
use deno_core::url::Url;
use deno_core::v8;
use deno_core::CompiledWasmModuleStore;
@@ -21,7 +20,6 @@ use deno_core::ModuleLoader;
use deno_core::PollEventLoopOptions;
use deno_core::SharedArrayBufferStore;
use deno_core::SourceMapGetter;
-use deno_lockfile::Lockfile;
use deno_runtime::code_cache;
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
use deno_runtime::deno_fs;
@@ -47,7 +45,7 @@ use deno_semver::package::PackageReqReference;
use deno_terminal::colors;
use tokio::select;
-use crate::args::write_lockfile_if_has_changes;
+use crate::args::CliLockfile;
use crate::args::DenoSubcommand;
use crate::args::StorageKeyResolver;
use crate::errors;
@@ -139,7 +137,7 @@ struct SharedWorkerState {
fs: Arc<dyn deno_fs::FileSystem>,
maybe_file_watcher_communicator: Option<Arc<WatcherCommunicator>>,
maybe_inspector_server: Option<Arc<InspectorServer>>,
- maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
+ maybe_lockfile: Option<Arc<CliLockfile>>,
feature_checker: Arc<FeatureChecker>,
node_ipc: Option<i64>,
enable_future_features: bool,
@@ -412,7 +410,7 @@ impl CliMainWorkerFactory {
fs: Arc<dyn deno_fs::FileSystem>,
maybe_file_watcher_communicator: Option<Arc<WatcherCommunicator>>,
maybe_inspector_server: Option<Arc<InspectorServer>>,
- maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
+ maybe_lockfile: Option<Arc<CliLockfile>>,
feature_checker: Arc<FeatureChecker>,
options: CliMainWorkerOptions,
node_ipc: Option<i64>,
@@ -529,7 +527,7 @@ impl CliMainWorkerFactory {
// For npm binary commands, ensure that the lockfile gets updated
// so that we can re-use the npm resolution the next time it runs
// for better performance
- write_lockfile_if_has_changes(&mut lockfile.lock())?;
+ lockfile.write_if_changed()?;
}
(node_resolution.into_url(), is_main_cjs)