diff options
Diffstat (limited to 'cli/standalone')
-rw-r--r-- | cli/standalone/binary.rs | 8 | ||||
-rw-r--r-- | cli/standalone/virtual_fs.rs | 51 |
2 files changed, 40 insertions, 19 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index d1a5863ee..de7b3f6ec 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -568,9 +568,16 @@ impl<'a> DenoCompileBinaryWriter<'a> { } fn build_vfs(&self) -> Result<VfsBuilder, AnyError> { + fn maybe_warn_different_system(system_info: &NpmSystemInfo) { + if system_info != &NpmSystemInfo::default() { + log::warn!("{} The node_modules directory may be incompatible with the target system.", crate::colors::yellow("Warning")); + } + } + match self.npm_resolver.as_inner() { InnerCliNpmResolverRef::Managed(npm_resolver) => { if let Some(node_modules_path) = npm_resolver.root_node_modules_path() { + maybe_warn_different_system(&self.npm_system_info); let mut builder = VfsBuilder::new(node_modules_path.clone())?; builder.add_dir_recursive(node_modules_path)?; Ok(builder) @@ -593,6 +600,7 @@ impl<'a> DenoCompileBinaryWriter<'a> { } } InnerCliNpmResolverRef::Byonm(npm_resolver) => { + maybe_warn_different_system(&self.npm_system_info); // the root_node_modules directory will always exist for byonm let node_modules_path = npm_resolver.root_node_modules_path().unwrap(); let parent_path = node_modules_path.parent().unwrap(); diff --git a/cli/standalone/virtual_fs.rs b/cli/standalone/virtual_fs.rs index ee870611b..fe79477d3 100644 --- a/cli/standalone/virtual_fs.rs +++ b/cli/standalone/virtual_fs.rs @@ -94,27 +94,40 @@ impl VfsBuilder { } else if file_type.is_file() { self.add_file_at_path(&path)?; } else if file_type.is_symlink() { - let target = util::fs::canonicalize_path(&path) - .with_context(|| format!("Reading symlink {}", path.display()))?; - if let Err(StripRootError { .. }) = self.add_symlink(&path, &target) { - if target.is_file() { - // this may change behavior, so warn the user about it - log::warn!( - "Symlink target is outside '{}'. Inlining symlink at '{}' to '{}' as file.", - self.root_path.display(), - path.display(), - target.display(), - ); - // inline the symlink and make the target file - let file_bytes = std::fs::read(&target) - .with_context(|| format!("Reading {}", path.display()))?; - self.add_file(&path, file_bytes)?; - } else { + match util::fs::canonicalize_path(&path) { + Ok(target) => { + if let Err(StripRootError { .. }) = self.add_symlink(&path, &target) + { + if target.is_file() { + // this may change behavior, so warn the user about it + log::warn!( + "{} Symlink target is outside '{}'. Inlining symlink at '{}' to '{}' as file.", + crate::colors::yellow("Warning"), + self.root_path.display(), + path.display(), + target.display(), + ); + // inline the symlink and make the target file + let file_bytes = std::fs::read(&target) + .with_context(|| format!("Reading {}", path.display()))?; + self.add_file(&path, file_bytes)?; + } else { + log::warn!( + "{} Symlink target is outside '{}'. Excluding symlink at '{}' with target '{}'.", + crate::colors::yellow("Warning"), + self.root_path.display(), + path.display(), + target.display(), + ); + } + } + } + Err(err) => { log::warn!( - "Symlink target is outside '{}'. Excluding symlink at '{}' with target '{}'.", - self.root_path.display(), + "{} Failed resolving symlink. Ignoring.\n Path: {}\n Message: {:#}", + crate::colors::yellow("Warning"), path.display(), - target.display(), + err ); } } |