From cc8046fcfa646db4415ea663df206b5ec136ff17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 11 Jul 2019 00:37:20 +0200 Subject: [PATCH] fix for '-' arg after script name --- cli/flags.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cli/flags.rs b/cli/flags.rs index b3fc11380ce673..de19a4de5946cf 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -586,7 +586,7 @@ fn parse_script_args( continue; } - if !arg.starts_with('-') { + if !arg.starts_with('-') || arg == "-" { argv.push(arg.to_string()); continue; } @@ -1539,5 +1539,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"]); } }