diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-06-15 16:08:11 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-06-15 07:08:11 -0700 |
commit | 061f6dd4832320ff654ee2a7a07901852b702639 (patch) | |
tree | 0d5145519e8265db26d5a175a456b652b3b13fae | |
parent | 77737707e4e07d7421d9a4f813d6dcd27ecf54fe (diff) |
fix deno install (#2529)
-rw-r--r-- | cli/flags.rs | 82 |
1 files changed, 73 insertions, 9 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index a4cbd2133..d3166441c 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -621,13 +621,14 @@ pub fn flags_from_vec( match install_match.subcommand() { (script_url, Some(script_match)) => { argv.extend(vec![exe_name.to_string(), script_url.to_string()]); - let flags: Vec<String> = script_match - .values_of("") - .unwrap() - .map(String::from) - .collect(); - argv.extend(flags); - + if script_match.is_present("") { + let flags: Vec<String> = script_match + .values_of("") + .unwrap() + .map(String::from) + .collect(); + argv.extend(flags); + } DenoSubcommand::Install } _ => unreachable!(), @@ -1235,7 +1236,7 @@ mod tests { } ); assert_eq!(subcommand, DenoSubcommand::Run); - assert_eq!(argv, svec!["deno", "script.ts"]) + assert_eq!(argv, svec!["deno", "script.ts"]); } #[test] @@ -1257,6 +1258,69 @@ mod tests { } ); assert_eq!(subcommand, DenoSubcommand::Run); - assert_eq!(argv, svec!["deno", "script.ts"]) + assert_eq!(argv, svec!["deno", "script.ts"]); + } + + #[test] + fn test_flags_from_vec_30() { + let (flags, subcommand, argv) = flags_from_vec(svec![ + "deno", + "install", + "deno_colors", + "https://deno.land/std/examples/colors.ts" + ]); + assert_eq!( + flags, + DenoFlags { + allow_write: true, + allow_net: true, + allow_read: true, + allow_env: true, + allow_run: true, + ..DenoFlags::default() + } + ); + assert_eq!(subcommand, DenoSubcommand::Install); + assert_eq!( + argv, + svec![ + "deno", + INSTALLER_URL, + "deno_colors", + "https://deno.land/std/examples/colors.ts" + ] + ); + + let (flags, subcommand, argv) = flags_from_vec(svec![ + "deno", + "install", + "file_server", + "https://deno.land/std/http/file_server.ts", + "--allow-net", + "--allow-read" + ]); + assert_eq!( + flags, + DenoFlags { + allow_write: true, + allow_net: true, + allow_read: true, + allow_env: true, + allow_run: true, + ..DenoFlags::default() + } + ); + assert_eq!(subcommand, DenoSubcommand::Install); + assert_eq!( + argv, + svec![ + "deno", + INSTALLER_URL, + "file_server", + "https://deno.land/std/http/file_server.ts", + "--allow-net", + "--allow-read" + ] + ); } } |