1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(task): remove --no-config as task subcommand argument (#14983)

This commit is contained in:
Geert-Jan Zwiers 2022-06-28 21:47:51 +02:00 committed by GitHub
parent 0f6a5c5fc2
commit 5b7bcefa11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1055,7 +1055,8 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
// deno-fmt-ignore-file", // deno-fmt-ignore-file",
) )
.args(config_args()) .arg(config_arg())
.arg(no_config_arg())
.arg( .arg(
Arg::new("check") Arg::new("check")
.long("check") .long("check")
@ -1165,7 +1166,8 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
) )
// TODO(lucacasonato): remove for 2.0 // TODO(lucacasonato): remove for 2.0
.arg(no_check_arg().hide(true)) .arg(no_check_arg().hide(true))
.args(config_args()) .arg(no_config_arg())
.arg(config_arg())
.arg(import_map_arg()) .arg(import_map_arg())
.arg( .arg(
Arg::new("json") Arg::new("json")
@ -1344,7 +1346,8 @@ Ignore linting a file by adding an ignore comment at the top of the file:
.conflicts_with("rules") .conflicts_with("rules")
.help("Exclude lint rules"), .help("Exclude lint rules"),
) )
.args(config_args()) .arg(no_config_arg())
.arg(config_arg())
.arg( .arg(
Arg::new("ignore") Arg::new("ignore")
.long("ignore") .long("ignore")
@ -1435,7 +1438,7 @@ Specifying the filename '-' to read the file from stdin.
fn task_subcommand<'a>() -> Command<'a> { fn task_subcommand<'a>() -> Command<'a> {
Command::new("task") Command::new("task")
.trailing_var_arg(true) .trailing_var_arg(true)
.args(config_args()) .arg(config_arg())
.arg( .arg(
Arg::new("cwd") Arg::new("cwd")
.long("cwd") .long("cwd")
@ -1687,7 +1690,8 @@ Remote modules and multiple modules may also be specified:
) )
.takes_value(false), .takes_value(false),
) )
.args(config_args()) .arg(no_config_arg())
.arg(config_arg())
.arg(import_map_arg()) .arg(import_map_arg())
.arg(lock_arg()) .arg(lock_arg())
.arg(reload_arg()) .arg(reload_arg())
@ -1698,7 +1702,8 @@ fn compile_args(app: Command) -> Command {
app app
.arg(import_map_arg()) .arg(import_map_arg())
.arg(no_remote_arg()) .arg(no_remote_arg())
.args(config_args()) .arg(no_config_arg())
.arg(config_arg())
.arg(no_check_arg()) .arg(no_check_arg())
.arg(check_arg()) .arg(check_arg())
.arg(reload_arg()) .arg(reload_arg())
@ -1711,7 +1716,8 @@ fn compile_args_without_check_args(app: Command) -> Command {
app app
.arg(import_map_arg()) .arg(import_map_arg())
.arg(no_remote_arg()) .arg(no_remote_arg())
.args(config_args()) .arg(config_arg())
.arg(no_config_arg())
.arg(reload_arg()) .arg(reload_arg())
.arg(lock_arg()) .arg(lock_arg())
.arg(lock_write_arg()) .arg(lock_write_arg())
@ -2095,22 +2101,22 @@ static CONFIG_HELP: Lazy<String> = Lazy::new(|| {
) )
}); });
fn config_args<'a>() -> [Arg<'a>; 2] { fn config_arg<'a>() -> Arg<'a> {
[ Arg::new("config")
Arg::new("config") .short('c')
.short('c') .long("config")
.long("config") .value_name("FILE")
.value_name("FILE") .help("Specify the configuration file")
.help("Specify the configuration file") .long_help(CONFIG_HELP.as_str())
.long_help(CONFIG_HELP.as_str()) .takes_value(true)
.takes_value(true) .value_hint(ValueHint::FilePath)
.value_hint(ValueHint::FilePath) }
.conflicts_with("no-config"),
Arg::new("no-config") fn no_config_arg<'a>() -> Arg<'a> {
.long("no-config") Arg::new("no-config")
.help("Disable automatic loading of the configuration file.") .long("no-config")
.conflicts_with("config"), .help("Disable automatic loading of the configuration file.")
] .conflicts_with("config")
} }
fn no_remote_arg<'a>() -> Arg<'a> { fn no_remote_arg<'a>() -> Arg<'a> {
@ -2551,7 +2557,11 @@ fn task_parse(
matches: &clap::ArgMatches, matches: &clap::ArgMatches,
raw_args: &[String], raw_args: &[String],
) { ) {
config_args_parse(flags, matches); flags.config_flag = if let Some(config) = matches.value_of("config") {
ConfigFlag::Path(config.to_string())
} else {
ConfigFlag::Discover
};
let mut task_flags = TaskFlags { let mut task_flags = TaskFlags {
cwd: None, cwd: None,
@ -5786,6 +5796,12 @@ mod tests {
); );
} }
#[test]
fn task_subcommand_noconfig_invalid() {
let r = flags_from_vec(svec!["deno", "task", "--no-config"]);
assert_eq!(r.unwrap_err().kind(), clap::ErrorKind::UnknownArgument);
}
#[test] #[test]
fn bench_with_flags() { fn bench_with_flags() {
let r = flags_from_vec(svec![ let r = flags_from_vec(svec![