0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(task): support forwarding lone double hyphen (#14436)

This commit is contained in:
David Sherret 2022-04-29 19:51:10 -04:00 committed by GitHub
parent 7f520e7206
commit 0e3581ae2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2509,14 +2509,10 @@ fn task_parse(
if let Some(task) = matches.value_of("task") {
task_name = task.to_string();
if let Some(task_args) = matches.values_of("task_args") {
// forward the `--` to the deno task
if let Some(index) = matches.index_of("task_args") {
if raw_args[index] == "--" {
flags.argv.push("--".to_string());
}
}
flags.argv.extend(task_args.map(String::from));
if let Some(index) = matches.index_of("task") {
flags
.argv
.extend(raw_args[index + 2..].iter().map(String::from));
}
}
@ -5545,6 +5541,22 @@ mod tests {
);
}
#[test]
fn task_subcommand_double_hyphen_only() {
// edge case, but it should forward
let r = flags_from_vec(svec!["deno", "task", "build", "--"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Task(TaskFlags {
task: "build".to_string(),
}),
argv: svec!["--"],
..Flags::default()
}
);
}
#[test]
fn task_following_arg() {
let r = flags_from_vec(svec!["deno", "task", "build", "-1", "--test"]);