From 28aa489de9cd4f995ec2fc02e2c9d224e89f4c01 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 10 May 2023 20:06:59 -0400 Subject: feat(compile): unstable npm and node specifier support (#19005) This is the initial support for npm and node specifiers in `deno compile`. The npm packages are included in the binary and read from it via a virtual file system. This also supports the `--node-modules-dir` flag, dependencies specified in a package.json, and npm binary commands (ex. `deno compile --unstable npm:cowsay`) Closes #16632 --- cli/util/fs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cli/util') diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 9d3c6fccb..94ec24fe6 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -92,12 +92,19 @@ pub fn canonicalize_path(path: &Path) -> Result { /// subsequently be created along this path by some other code. pub fn canonicalize_path_maybe_not_exists( path: &Path, +) -> Result { + canonicalize_path_maybe_not_exists_with_fs(path, canonicalize_path) +} + +pub fn canonicalize_path_maybe_not_exists_with_fs( + path: &Path, + canonicalize: impl Fn(&Path) -> Result, ) -> Result { let path = path.to_path_buf().clean(); let mut path = path.as_path(); let mut names_stack = Vec::new(); loop { - match canonicalize_path(path) { + match canonicalize(path) { Ok(mut canonicalized_path) => { for name in names_stack.into_iter().rev() { canonicalized_path = canonicalized_path.join(name); -- cgit v1.2.3