diff options
| author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-06-28 17:18:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-28 17:18:21 -0700 |
| commit | bc8a0e6e68547cf07a246b8b6c886de155dc8282 (patch) | |
| tree | a3540b01218c4674c399eb770c0f08e5ba594793 /cli/module_loader.rs | |
| parent | 2ddae872f956ddd84656a302aa5f6b752f6a6ab5 (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/module_loader.rs')
| -rw-r--r-- | cli/module_loader.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 5752c50aa..ed1a9526f 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -9,7 +9,7 @@ use std::str; use std::sync::Arc; use crate::args::jsr_url; -use crate::args::write_lockfile_if_has_changes; +use crate::args::CliLockfile; use crate::args::CliOptions; use crate::args::DenoSubcommand; use crate::args::TsTypeLib; @@ -45,7 +45,6 @@ use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::futures::future::FutureExt; use deno_core::futures::Future; -use deno_core::parking_lot::Mutex; use deno_core::resolve_url; use deno_core::ModuleCodeString; use deno_core::ModuleLoader; @@ -65,7 +64,6 @@ use deno_graph::JsonModule; use deno_graph::Module; use deno_graph::ModuleGraph; use deno_graph::Resolution; -use deno_lockfile::Lockfile; use deno_runtime::code_cache; use deno_runtime::deno_node::NodeResolutionMode; use deno_runtime::deno_permissions::PermissionsContainer; @@ -116,7 +114,7 @@ pub async fn load_top_level_deps(factory: &CliFactory) -> Result<(), AnyError> { pub struct ModuleLoadPreparer { options: Arc<CliOptions>, - lockfile: Option<Arc<Mutex<Lockfile>>>, + lockfile: Option<Arc<CliLockfile>>, module_graph_builder: Arc<ModuleGraphBuilder>, progress_bar: ProgressBar, type_checker: Arc<TypeChecker>, @@ -126,7 +124,7 @@ impl ModuleLoadPreparer { #[allow(clippy::too_many_arguments)] pub fn new( options: Arc<CliOptions>, - lockfile: Option<Arc<Mutex<Lockfile>>>, + lockfile: Option<Arc<CliLockfile>>, module_graph_builder: Arc<ModuleGraphBuilder>, progress_bar: ProgressBar, type_checker: Arc<TypeChecker>, @@ -177,7 +175,7 @@ impl ModuleLoadPreparer { // write the lockfile if there is one if let Some(lockfile) = &self.lockfile { - write_lockfile_if_has_changes(&mut lockfile.lock())?; + lockfile.write_if_changed()?; } drop(_pb_clear_guard); |
