From e372fc73e806faeeb3c67df2d5b10a63fe5e8213 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 6 Dec 2023 16:36:06 -0500 Subject: 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. --- cli/args/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cli/args/mod.rs') 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 { + 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 } -- cgit v1.2.3