summaryrefslogtreecommitdiff
path: root/cli/args/mod.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/args/mod.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/args/mod.rs')
-rw-r--r--cli/args/mod.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 9e63ce889..187304d5d 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -34,16 +34,13 @@ pub use deno_config::TsConfigType;
pub use deno_config::TsTypeLib;
pub use deno_config::WorkspaceConfig;
pub use flags::*;
-pub use lockfile::read_lockfile_at_path;
-pub use lockfile::write_lockfile_if_has_changes;
-pub use lockfile::Lockfile;
+pub use lockfile::CliLockfile;
pub use package_json::PackageJsonDepsProvider;
use deno_ast::ModuleSpecifier;
use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
-use deno_core::parking_lot::Mutex;
use deno_core::serde_json;
use deno_core::url::Url;
use deno_runtime::deno_node::PackageJson;
@@ -812,7 +809,7 @@ pub struct CliOptions {
maybe_config_file: Option<ConfigFile>,
maybe_package_json: Option<Arc<PackageJson>>,
npmrc: Arc<ResolvedNpmRc>,
- maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
+ maybe_lockfile: Option<Arc<CliLockfile>>,
overrides: CliOptionOverrides,
maybe_workspace_config: Option<WorkspaceConfig>,
pub disable_deprecated_api_warning: bool,
@@ -824,7 +821,7 @@ impl CliOptions {
flags: Flags,
initial_cwd: PathBuf,
maybe_config_file: Option<ConfigFile>,
- maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
+ maybe_lockfile: Option<Arc<CliLockfile>>,
maybe_package_json: Option<Arc<PackageJson>>,
npmrc: Arc<ResolvedNpmRc>,
force_global_cache: bool,
@@ -958,7 +955,7 @@ impl CliOptions {
}),
)?;
- let maybe_lock_file = lockfile::discover(
+ let maybe_lock_file = CliLockfile::discover(
&flags,
maybe_config_file.as_ref(),
maybe_package_json.as_deref(),
@@ -967,7 +964,7 @@ impl CliOptions {
flags,
initial_cwd,
maybe_config_file,
- maybe_lock_file.map(|l| Arc::new(Mutex::new(l))),
+ maybe_lock_file.map(Arc::new),
maybe_package_json,
npmrc,
false,
@@ -1353,7 +1350,7 @@ impl CliOptions {
Ok(Some(InspectorServer::new(host, version::get_user_agent())?))
}
- pub fn maybe_lockfile(&self) -> Option<Arc<Mutex<Lockfile>>> {
+ pub fn maybe_lockfile(&self) -> Option<Arc<CliLockfile>> {
self.maybe_lockfile.clone()
}