diff options
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index d024f6576..0c3caf0a1 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -317,6 +317,7 @@ pub struct Flags { pub lock: Option<PathBuf>, pub log_level: Option<Level>, pub no_remote: bool, + pub no_lock: bool, pub no_npm: bool, pub no_prompt: bool, pub reload: bool, @@ -1772,6 +1773,7 @@ fn compile_args(app: Command) -> Command { .arg(reload_arg()) .arg(lock_arg()) .arg(lock_write_arg()) + .arg(no_lock_arg()) .arg(ca_file_arg()) } @@ -1786,6 +1788,7 @@ fn compile_args_without_check_args(app: Command) -> Command { .arg(reload_arg()) .arg(lock_arg()) .arg(lock_write_arg()) + .arg(no_lock_arg()) .arg(ca_file_arg()) } @@ -2160,6 +2163,14 @@ fn lock_write_arg<'a>() -> Arg<'a> { .help("Force overwriting the lock file.") } +fn no_lock_arg<'a>() -> Arg<'a> { + Arg::new("no-lock") + .long("no-lock") + .help("Disable auto discovery of the lock file.") + .conflicts_with("lock") + .conflicts_with("lock-write") +} + static CONFIG_HELP: Lazy<String> = Lazy::new(|| { format!( "The configuration file can be used to configure different aspects of \ @@ -3097,6 +3108,9 @@ fn lock_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) { if matches.is_present("lock-write") { flags.lock_write = true; } + if matches.is_present("no-lock") { + flags.no_lock = true; + } } fn lock_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) { @@ -5343,6 +5357,18 @@ mod tests { } ); + let r = flags_from_vec(svec!["deno", "run", "--no-lock", "script.ts"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Run(RunFlags { + script: "script.ts".to_string(), + }), + no_lock: true, + ..Flags::default() + } + ); + let r = flags_from_vec(svec![ "deno", "run", @@ -5393,6 +5419,19 @@ mod tests { ..Flags::default() } ); + + let r = + flags_from_vec(svec!["deno", "run", "--lock", "--no-lock", "script.ts"]); + assert!(r.is_err(),); + + let r = flags_from_vec(svec![ + "deno", + "run", + "--lock-write", + "--no-lock", + "script.ts" + ]); + assert!(r.is_err(),); } #[test] |