diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-10 20:06:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 20:06:59 -0400 |
commit | 28aa489de9cd4f995ec2fc02e2c9d224e89f4c01 (patch) | |
tree | b316937a47fe9c8f9f6768bc13b9a686c07cf42f /cli/args/mod.rs | |
parent | 5fd74bfa1c5ed514c3e19fdb2e8590fe251d3ee6 (diff) |
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
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index b5975536a..31035fdd0 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -33,6 +33,7 @@ pub use config_file::TsTypeLib; pub use flags::*; pub use lockfile::Lockfile; pub use lockfile::LockfileError; +pub use package_json::PackageJsonDepsProvider; use deno_ast::ModuleSpecifier; use deno_core::anyhow::anyhow; @@ -556,7 +557,7 @@ struct CliOptionOverrides { import_map_specifier: Option<Option<ModuleSpecifier>>, } -/// Holds the resolved options of many sources used by sub commands +/// Holds the resolved options of many sources used by subcommands /// and provides some helper function for creating common objects. pub struct CliOptions { // the source of the options is a detail the rest of the @@ -1303,6 +1304,16 @@ fn has_flag_env_var(name: &str) -> bool { matches!(value.as_ref().map(|s| s.as_str()), Ok("1")) } +pub fn npm_pkg_req_ref_to_binary_command( + req_ref: &NpmPackageReqReference, +) -> String { + let binary_name = req_ref + .sub_path + .as_deref() + .unwrap_or(req_ref.req.name.as_str()); + binary_name.to_string() +} + #[cfg(test)] mod test { use super::*; |