summaryrefslogtreecommitdiff
path: root/cli/task_runner.rs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-07-15 12:11:09 -0700
committerGitHub <noreply@github.com>2024-07-15 12:11:09 -0700
commit04f9db5b2217fe06f88e76146aac6362ff0b0b86 (patch)
treeaa4becb2529141de3e6bb8d3ba430f3c7e036902 /cli/task_runner.rs
parent29186d7e5963f2398b28ee2c043b27e4881075ef (diff)
fix(node): Fix `--allow-scripts` with no `deno.json` (#24533)
We would resolve the wrong package.json, resulting in an inability to run CJS (or other node-mode) scripts
Diffstat (limited to 'cli/task_runner.rs')
-rw-r--r--cli/task_runner.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/task_runner.rs b/cli/task_runner.rs
index e8937590d..7653594e5 100644
--- a/cli/task_runner.rs
+++ b/cli/task_runner.rs
@@ -164,7 +164,9 @@ impl ShellCommand for NpmCommand {
}
}
-pub struct NodeCommand;
+pub struct NodeCommand {
+ pub force_node_modules_dir: bool,
+}
impl ShellCommand for NodeCommand {
fn execute(
@@ -191,6 +193,9 @@ impl ShellCommand for NodeCommand {
.execute(context);
}
args.extend(["run", "-A"].into_iter().map(|s| s.to_string()));
+ if self.force_node_modules_dir {
+ args.push("--node-modules-dir=true".to_string());
+ }
args.extend(context.args.iter().cloned());
let mut state = context.state;
@@ -303,6 +308,7 @@ impl ShellCommand for NodeModulesFileRunCommand {
let mut args = vec![
"run".to_string(),
"--ext=js".to_string(),
+ "--node-modules-dir=true".to_string(),
"-A".to_string(),
self.path.to_string_lossy().to_string(),
];