summaryrefslogtreecommitdiff
path: root/cli/factory.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/factory.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/factory.rs')
-rw-r--r--cli/factory.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/cli/factory.rs b/cli/factory.rs
index c2a5425c0..56a28b6d9 100644
--- a/cli/factory.rs
+++ b/cli/factory.rs
@@ -1,10 +1,10 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use crate::args::deno_json::deno_json_deps;
+use crate::args::CliLockfile;
use crate::args::CliOptions;
use crate::args::DenoSubcommand;
use crate::args::Flags;
-use crate::args::Lockfile;
use crate::args::PackageJsonDepsProvider;
use crate::args::StorageKeyResolver;
use crate::args::TsConfigType;
@@ -56,7 +56,6 @@ use std::path::PathBuf;
use deno_core::error::AnyError;
use deno_core::futures::FutureExt;
-use deno_core::parking_lot::Mutex;
use deno_core::FeatureChecker;
use deno_lockfile::WorkspaceMemberConfig;
@@ -156,7 +155,7 @@ struct CliFactoryServices {
emitter: Deferred<Arc<Emitter>>,
fs: Deferred<Arc<dyn deno_fs::FileSystem>>,
main_graph_container: Deferred<Arc<MainModuleGraphContainer>>,
- lockfile: Deferred<Option<Arc<Mutex<Lockfile>>>>,
+ lockfile: Deferred<Option<Arc<CliLockfile>>>,
maybe_import_map: Deferred<Option<Arc<ImportMap>>>,
maybe_inspector_server: Deferred<Option<Arc<InspectorServer>>>,
root_cert_store_provider: Deferred<Arc<dyn RootCertStoreProvider>>,
@@ -304,8 +303,8 @@ impl CliFactory {
self.services.fs.get_or_init(|| Arc::new(deno_fs::RealFs))
}
- pub fn maybe_lockfile(&self) -> &Option<Arc<Mutex<Lockfile>>> {
- fn check_no_npm(lockfile: &Mutex<Lockfile>, options: &CliOptions) -> bool {
+ pub fn maybe_lockfile(&self) -> &Option<Arc<CliLockfile>> {
+ fn check_no_npm(lockfile: &CliLockfile, options: &CliOptions) -> bool {
if options.no_npm() {
return true;
}
@@ -315,7 +314,7 @@ impl CliFactory {
options
.maybe_package_json()
.map(|package_json| {
- package_json.path.parent() != lockfile.lock().filename.parent()
+ package_json.path.parent() != lockfile.filename.parent()
})
.unwrap_or(false)
}
@@ -337,7 +336,6 @@ impl CliFactory {
.unwrap_or_default()
})
.unwrap_or_default();
- let mut lockfile = lockfile.lock();
let config = match self.options.maybe_workspace_config() {
Some(workspace_config) => deno_lockfile::WorkspaceConfig {
root: WorkspaceMemberConfig {