Skip to content

Commit

Permalink
make importmap flag global (denoland#2687)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Jul 27, 2019
1 parent 89e6792 commit 729c4e9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
38 changes: 28 additions & 10 deletions cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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]
Expand Down
Empty file added tests/036_import_map_fetch.out
Empty file.
2 changes: 2 additions & 0 deletions tests/036_import_map_fetch.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
args: fetch --reload --importmap=tests/importmaps/import_map.json tests/importmaps/test.ts
output: tests/036_import_map_fetch.out

0 comments on commit 729c4e9

Please sign in to comment.