From 9ac405d587ca1465debd4a65a09324b7a6b2c04f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 29 Nov 2023 09:32:23 -0500 Subject: feat(compile): support "bring your own node_modules" in deno compile (#21377) Not tested thoroughly. This is a good start. Closes #21350 --- cli/util/fs.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cli/util') diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 33eb3af9d..4881d0815 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -6,6 +6,7 @@ pub use deno_core::normalize_path; use deno_core::unsync::spawn_blocking; use deno_core::ModuleSpecifier; use deno_runtime::deno_crypto::rand; +use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::PathClean; use std::borrow::Cow; use std::env::current_dir; @@ -187,10 +188,19 @@ pub fn canonicalize_path(path: &Path) -> Result { pub fn canonicalize_path_maybe_not_exists( path: &Path, ) -> Result { - canonicalize_path_maybe_not_exists_with_fs(path, canonicalize_path) + canonicalize_path_maybe_not_exists_with_custom_fn(path, canonicalize_path) } pub fn canonicalize_path_maybe_not_exists_with_fs( + path: &Path, + fs: &dyn FileSystem, +) -> Result { + canonicalize_path_maybe_not_exists_with_custom_fn(path, |path| { + fs.realpath_sync(path).map_err(|err| err.into_io_error()) + }) +} + +fn canonicalize_path_maybe_not_exists_with_custom_fn( path: &Path, canonicalize: impl Fn(&Path) -> Result, ) -> Result { -- cgit v1.2.3