From 729c4e9377c2112d51cefb6eb0c723cbaf2a1ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 27 Jul 2019 16:37:03 +0200 Subject: make importmap flag global (#2687) --- cli/flags.rs | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'cli') diff --git a/cli/flags.rs b/cli/flags.rs index ad08b5a7a..978b0409f 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -100,16 +100,6 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { Arg::with_name("no-fetch") .long("no-fetch") .help("Do not download remote modules"), - ).arg( - Arg::with_name("importmap") - .long("importmap") - .value_name("FILE") - .help("Load import map file") - .long_help( - "Load import map file -Specification: https://wicg.github.io/import-maps/ -Examples: https://github.com/WICG/import-maps#the-import-map", - ).takes_value(true), ) } @@ -168,6 +158,18 @@ To get help on the another subcommands (run in this case): .help("Load compiler configuration file") .takes_value(true) .global(true), + ).arg( + Arg::with_name("importmap") + .long("importmap") + .value_name("FILE") + .help("Load import map file") + .long_help( + "Load import map file +Specification: https://wicg.github.io/import-maps/ +Examples: https://github.com/WICG/import-maps#the-import-map", + ) + .takes_value(true) + .global(true), ).arg( Arg::with_name("seed") .long("seed") @@ -1368,6 +1370,22 @@ mod tests { ); assert_eq!(subcommand, DenoSubcommand::Run); assert_eq!(argv, svec!["deno", "script.ts"]); + + let (flags, subcommand, argv) = flags_from_vec(svec![ + "deno", + "fetch", + "--importmap=importmap.json", + "script.ts" + ]); + assert_eq!( + flags, + DenoFlags { + import_map_path: Some("importmap.json".to_owned()), + ..DenoFlags::default() + } + ); + assert_eq!(subcommand, DenoSubcommand::Fetch); + assert_eq!(argv, svec!["deno", "script.ts"]); } #[test] -- cgit v1.2.3