Skip to content

Commit

Permalink
fix for '-' arg after script name (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Jul 11, 2019
1 parent d7fa8c3 commit 963d56f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ fn parse_script_args(
continue;
}

if !arg.starts_with('-') {
if !arg.starts_with('-') || arg == "-" {
argv.push(arg.to_string());
continue;
}
Expand Down Expand Up @@ -1541,5 +1541,23 @@ mod tests {
);
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts", "--help", "--foo", "bar"]);

let (flags, subcommand, argv) =
flags_from_vec(svec!["deno", "script.ts", "foo", "bar"]);
assert_eq!(flags, DenoFlags::default());
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts", "foo", "bar"]);

let (flags, subcommand, argv) =
flags_from_vec(svec!["deno", "script.ts", "-"]);
assert_eq!(flags, DenoFlags::default());
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts", "-"]);

let (flags, subcommand, argv) =
flags_from_vec(svec!["deno", "script.ts", "-", "foo", "bar"]);
assert_eq!(flags, DenoFlags::default());
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts", "-", "foo", "bar"]);
}
}

0 comments on commit 963d56f

Please sign in to comment.