diff options
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index afd505f44..77e09e1cb 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -312,6 +312,7 @@ pub struct Flags { pub lock: Option<PathBuf>, pub log_level: Option<Level>, pub no_remote: bool, + pub no_npm: bool, pub no_prompt: bool, pub reload: bool, pub seed: Option<u64>, @@ -1732,6 +1733,7 @@ fn compile_args(app: Command) -> Command { app .arg(import_map_arg()) .arg(no_remote_arg()) + .arg(no_npm_arg()) .arg(no_config_arg()) .arg(config_arg()) .arg(no_check_arg()) @@ -1746,6 +1748,7 @@ fn compile_args_without_check_args(app: Command) -> Command { app .arg(import_map_arg()) .arg(no_remote_arg()) + .arg(no_npm_arg()) .arg(config_arg()) .arg(no_config_arg()) .arg(reload_arg()) @@ -2140,6 +2143,12 @@ fn no_remote_arg<'a>() -> Arg<'a> { .help("Do not resolve remote modules") } +fn no_npm_arg<'a>() -> Arg<'a> { + Arg::new("no-npm") + .long("no-npm") + .help("Do not resolve npm modules") +} + fn unsafely_ignore_certificate_errors_arg<'a>() -> Arg<'a> { Arg::new("unsafely-ignore-certificate-errors") .long("unsafely-ignore-certificate-errors") @@ -2785,6 +2794,7 @@ fn vendor_parse(flags: &mut Flags, matches: &clap::ArgMatches) { fn compile_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) { import_map_arg_parse(flags, matches); no_remote_arg_parse(flags, matches); + no_npm_arg_parse(flags, matches); config_args_parse(flags, matches); no_check_arg_parse(flags, matches); check_arg_parse(flags, matches); @@ -2799,6 +2809,7 @@ fn compile_args_without_no_check_parse( ) { import_map_arg_parse(flags, matches); no_remote_arg_parse(flags, matches); + no_npm_arg_parse(flags, matches); config_args_parse(flags, matches); reload_arg_parse(flags, matches); lock_args_parse(flags, matches); @@ -3040,6 +3051,12 @@ fn no_remote_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) { } } +fn no_npm_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) { + if matches.is_present("no-npm") { + flags.no_npm = true; + } +} + fn inspect_arg_validate(val: &str) -> Result<(), String> { match val.parse::<SocketAddr>() { Ok(_) => Ok(()), @@ -4999,6 +5016,21 @@ mod tests { } #[test] + fn no_npm() { + let r = flags_from_vec(svec!["deno", "run", "--no-npm", "script.ts"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Run(RunFlags { + script: "script.ts".to_string(), + }), + no_npm: true, + ..Flags::default() + } + ); + } + + #[test] fn cached_only() { let r = flags_from_vec(svec!["deno", "run", "--cached-only", "script.ts"]); assert_eq!( |