Skip to content

Commit

Permalink
fix: bring back --no-fetch flag (denoland#2671)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Jul 20, 2019
1 parent a00d087 commit 34f212f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cli/flags.rs
Expand Up @@ -96,6 +96,10 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
Arg::with_name("no-prompt")
.long("no-prompt")
.help("Do not use prompts"),
).arg(
Arg::with_name("no-fetch")
.long("no-fetch")
.help("Do not download remote modules"),
).arg(
Arg::with_name("importmap")
.long("importmap")
Expand Down Expand Up @@ -552,6 +556,9 @@ fn parse_run_args(mut flags: DenoFlags, matches: &ArgMatches) -> DenoFlags {
if matches.is_present("no-prompt") {
flags.no_prompts = true;
}
if matches.is_present("no-fetch") {
flags.no_fetch = true;
}
flags.import_map_path = matches.value_of("importmap").map(ToOwned::to_owned);

flags
Expand Down Expand Up @@ -1560,4 +1567,19 @@ mod tests {
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts", "-", "foo", "bar"]);
}

#[test]
fn test_flags_from_vec_34() {
let (flags, subcommand, argv) =
flags_from_vec(svec!["deno", "--no-fetch", "script.ts"]);
assert_eq!(
flags,
DenoFlags {
no_fetch: true,
..DenoFlags::default()
}
);
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts"])
}
}
1 change: 1 addition & 0 deletions tests/035_no_fetch_flag.out
@@ -0,0 +1 @@
success true true true true true true true true
4 changes: 4 additions & 0 deletions tests/035_no_fetch_flag.test
@@ -0,0 +1,4 @@
# The output assumes 003_relative_import.ts has already been run earlier
# and its output is cached to $DENO_DIR.
args: --no-fetch http://127.0.0.1:4545/tests/019_media_types.ts
output: tests/035_no_fetch_flag.out

0 comments on commit 34f212f

Please sign in to comment.