1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

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
This commit is contained in:
Nathan Whitaker 2024-09-20 13:55:33 -07:00 committed by GitHub
parent 94bdebe399
commit 4b131d24a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()
}
)
}
}