diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-12-06 16:36:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 16:36:06 -0500 |
commit | e372fc73e806faeeb3c67df2d5b10a63fe5e8213 (patch) | |
tree | 8231a04ab1ea19dc4aa9d8e6be502cbf6c136ede /cli/args/mod.rs | |
parent | 7fdc3c8f1fc27be2ca7d4ff62b9fd8ecb3d24e61 (diff) |
fix(task): handle node_modules/.bin directory with byonm (#21386)
A bit hacky, but it works. Essentially, this will check for all the
scripts in the node_modules/.bin directory then force them to run with
Deno via deno_task_shell.
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index dd8de2a6f..3e61b50bd 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1306,6 +1306,25 @@ impl CliOptions { &self.flags.strace_ops } + pub fn take_binary_npm_command_name(&self) -> Option<String> { + match self.sub_command() { + DenoSubcommand::Run(flags) => { + const NPM_CMD_NAME_ENV_VAR_NAME: &str = "DENO_INTERNAL_NPM_CMD_NAME"; + match std::env::var(NPM_CMD_NAME_ENV_VAR_NAME) { + Ok(var) => { + // remove the env var so that child sub processes won't pick this up + std::env::remove_var(NPM_CMD_NAME_ENV_VAR_NAME); + Some(var) + } + Err(_) => NpmPackageReqReference::from_str(&flags.script) + .ok() + .map(|req_ref| npm_pkg_req_ref_to_binary_command(&req_ref)), + } + } + _ => None, + } + } + pub fn type_check_mode(&self) -> TypeCheckMode { self.flags.type_check_mode } |