diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2022-12-06 14:12:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-06 14:12:51 -0500 |
| commit | c03e0f3853490e804fe30fc566b45150061badc9 (patch) | |
| tree | 0f23dad9542c8cf80d0861c2932e2eb1b9e6fc3a /cli/tools/vendor | |
| parent | 3e47a27f4fa528b91ac60b07ee6931f47fed0bc5 (diff) | |
refactor: remove `deno_graph::Locker` usage (#16877)
This is just a straight refactor and doesn't make any improvements to
the code that could now be made.
Closes #16493
Diffstat (limited to 'cli/tools/vendor')
| -rw-r--r-- | cli/tools/vendor/build.rs | 17 | ||||
| -rw-r--r-- | cli/tools/vendor/mod.rs | 1 | ||||
| -rw-r--r-- | cli/tools/vendor/test.rs | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index b28038a67..bdb384e43 100644 --- a/cli/tools/vendor/build.rs +++ b/cli/tools/vendor/build.rs @@ -3,18 +3,22 @@ use std::fmt::Write as _; use std::path::Path; use std::path::PathBuf; +use std::sync::Arc; 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_graph::Module; use deno_graph::ModuleGraph; use deno_graph::ModuleKind; use import_map::ImportMap; use import_map::SpecifierMap; +use crate::args::Lockfile; use crate::cache::ParsedSourceCache; +use crate::graph_util::graph_lock_or_exit; use super::analyze::has_default_export; use super::import_map::build_import_map; @@ -57,6 +61,7 @@ pub fn build( parsed_source_cache: &ParsedSourceCache, output_dir: &Path, original_import_map: Option<&ImportMap>, + maybe_lockfile: Option<Arc<Mutex<Lockfile>>>, environment: &impl VendorEnvironment, ) -> Result<usize, AnyError> { assert!(output_dir.is_absolute()); @@ -68,18 +73,20 @@ pub fn build( } // build the graph - graph.lock()?; + if let Some(lockfile) = maybe_lockfile { + graph_lock_or_exit(&graph, &mut lockfile.lock()); + } - let graph_errors = graph.errors(); - if !graph_errors.is_empty() { - for err in &graph_errors { + let mut graph_errors = graph.errors().peekable(); + if graph_errors.peek().is_some() { + for err in graph_errors { log::error!("{}", err); } bail!("failed vendoring"); } // figure out how to map remote modules to local - let all_modules = graph.modules(); + let all_modules = graph.modules().collect::<Vec<_>>(); let remote_modules = all_modules .iter() .filter(|m| is_remote_specifier(&m.specifier)) diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs index a1057d838..ed0c69501 100644 --- a/cli/tools/vendor/mod.rs +++ b/cli/tools/vendor/mod.rs @@ -49,6 +49,7 @@ pub async fn vendor( &ps.parsed_source_cache, &output_dir, ps.maybe_import_map.as_deref(), + ps.lockfile.clone(), &build::RealVendorEnvironment, )?; diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs index ee779468b..c703357d8 100644 --- a/cli/tools/vendor/test.rs +++ b/cli/tools/vendor/test.rs @@ -234,6 +234,7 @@ impl VendorTestBuilder { &parsed_source_cache, &output_dir, self.original_import_map.as_ref(), + None, &self.environment, )?; @@ -273,7 +274,6 @@ async fn build_test_graph( is_dynamic: false, imports: None, resolver: resolver.as_ref().map(|r| r.as_graph_resolver()), - locker: None, module_analyzer: Some(analyzer), reporter: None, }, |
