summaryrefslogtreecommitdiff
path: root/cli/tools/vendor/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/vendor/build.rs')
-rw-r--r--cli/tools/vendor/build.rs17
1 files changed, 12 insertions, 5 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))