feat(flags): add deno check --all as new preferred alias for --remote (#16702)

Closes #16374
This commit is contained in:
David Sherret 2022-12-07 13:33:26 -05:00 committed by GitHub
parent 9c1ab39e19
commit 192f07bb7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 36 deletions

View file

@ -797,12 +797,20 @@ Future runs of this module will trigger no downloads or compilation unless \
fn check_subcommand<'a>() -> Command<'a> {
compile_args_without_check_args(Command::new("check"))
.arg(
Arg::new("remote")
.long("remote")
.help("Type-check all modules, including remote")
.conflicts_with("no-remote")
.arg(
Arg::new("all")
.long("all")
.help("Type-check all code, including remote modules and npm packages")
.conflicts_with("no-remote")
)
.arg(
// past alias for --all
Arg::new("remote")
.long("remote")
.help("Type-check all modules, including remote")
.conflicts_with("no-remote")
.hide(true)
)
.arg(
Arg::new("file")
.takes_value(true)
@ -2343,7 +2351,7 @@ fn check_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
.unwrap()
.map(String::from)
.collect();
if matches.is_present("remote") {
if matches.is_present("all") || matches.is_present("remote") {
flags.type_check_mode = TypeCheckMode::All;
}
flags.subcommand = DenoSubcommand::Check(CheckFlags { files });
@ -4001,26 +4009,28 @@ mod tests {
}
);
let r = flags_from_vec(svec!["deno", "check", "--remote", "script.ts"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Check(CheckFlags {
files: svec!["script.ts"],
}),
type_check_mode: TypeCheckMode::All,
..Flags::default()
}
);
for all_flag in ["--remote", "--all"] {
let r = flags_from_vec(svec!["deno", "check", all_flag, "script.ts"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Check(CheckFlags {
files: svec!["script.ts"],
}),
type_check_mode: TypeCheckMode::All,
..Flags::default()
}
);
let r = flags_from_vec(svec![
"deno",
"check",
"--remote",
"--no-remote",
"script.ts"
]);
assert_eq!(r.unwrap_err().kind(), clap::ErrorKind::ArgumentConflict);
let r = flags_from_vec(svec![
"deno",
"check",
all_flag,
"--no-remote",
"script.ts"
]);
assert_eq!(r.unwrap_err().kind(), clap::ErrorKind::ArgumentConflict);
}
}
#[test]

View file

@ -28,7 +28,7 @@ mod check {
});
itest!(check_all {
args: "check --quiet --remote check/check_all.ts",
args: "check --quiet --all check/check_all.ts",
output: "check/check_all.out",
http_server: true,
exit_code: 1,

View file

@ -264,7 +264,7 @@ mod npm {
});
itest!(check_all {
args: "check --remote npm/check_errors/main.ts",
args: "check --all npm/check_errors/main.ts",
output: "npm/check_errors/main_all.out",
envs: env_vars_for_npm_tests(),
http_server: true,
@ -320,7 +320,7 @@ mod npm {
});
itest!(types_entry_value_not_exists {
args: "check --remote npm/types_entry_value_not_exists/main.ts",
args: "check --all npm/types_entry_value_not_exists/main.ts",
output: "npm/types_entry_value_not_exists/main.out",
envs: env_vars_for_npm_tests(),
http_server: true,
@ -328,7 +328,7 @@ mod npm {
});
itest!(types_exports_import_types {
args: "check --remote npm/types_exports_import_types/main.ts",
args: "check --all npm/types_exports_import_types/main.ts",
output: "npm/types_exports_import_types/main.out",
envs: env_vars_for_npm_tests(),
http_server: true,
@ -336,7 +336,7 @@ mod npm {
});
itest!(types_no_types_entry {
args: "check --remote npm/types_no_types_entry/main.ts",
args: "check --all npm/types_no_types_entry/main.ts",
output: "npm/types_no_types_entry/main.out",
envs: env_vars_for_npm_tests(),
http_server: true,