summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-09-20 13:55:33 -0700
committerGitHub <noreply@github.com>2024-09-20 13:55:33 -0700
commit4b131d24a75ba6449c67461da4e5cf004bf865d1 (patch)
treeade617fd804df89a1cf7912ee8caba07409b8cdc /cli/args
parent94bdebe3998d503c625dbf093c40d7cb9d694d7c (diff)
fix(cli): Default to auto with --node-modules-dir flag (#25772)
Fixes a regression where we were ignoring `--node-modules-dir` if there was no value passed with it. We should instead default to "auto", to maintain compat with deno 1
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/flags.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 7f67f6702..a5ca78acc 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -3896,6 +3896,7 @@ fn node_modules_dir_arg() -> Arg {
Arg::new("node-modules-dir")
.long("node-modules-dir")
.num_args(0..=1)
+ .default_missing_value("auto")
.value_parser(clap::builder::ValueParser::new(parse_node_modules_dir_mode))
.value_name("MODE")
.require_equals(true)
@@ -8494,7 +8495,7 @@ mod tests {
watch: None,
bare: true,
}),
- node_modules_dir: None,
+ node_modules_dir: Some(NodeModulesDirMode::Auto),
code_cache_enabled: true,
..Flags::default()
}
@@ -10815,4 +10816,23 @@ mod tests {
"error: invalid value 'https://example.com': URLs are not supported, only domains and ips"
);
}
+
+ #[test]
+ fn node_modules_dir_default() {
+ let r =
+ flags_from_vec(svec!["deno", "run", "--node-modules-dir", "./foo.ts"]);
+ let flags = r.unwrap();
+ assert_eq!(
+ flags,
+ Flags {
+ subcommand: DenoSubcommand::Run(RunFlags {
+ script: "./foo.ts".into(),
+ ..Default::default()
+ }),
+ node_modules_dir: Some(NodeModulesDirMode::Auto),
+ code_cache_enabled: true,
+ ..Default::default()
+ }
+ )
+ }
}