summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/flags.rs29
-rw-r--r--cli/lib.rs14
-rw-r--r--cli/tests/037_fetch_multiple.out5
-rw-r--r--cli/tests/fetch/other.ts1
-rw-r--r--cli/tests/fetch/test.ts1
-rw-r--r--cli/tests/integration_tests.rs7
6 files changed, 53 insertions, 4 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 1eda8765e..a0d322e56 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -401,8 +401,10 @@ fn fetch_parse(flags: &mut DenoFlags, matches: &clap::ArgMatches) {
importmap_arg_parse(flags, matches);
config_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
- if let Some(file) = matches.value_of("file") {
- flags.argv.push(file.into());
+ if let Some(files) = matches.values_of("file") {
+ for file in files {
+ flags.argv.push(file.into());
+ }
}
}
@@ -525,7 +527,7 @@ fn fmt_subcommand<'a, 'b>() -> App<'a, 'b> {
deno fmt
deno fmt myfile1.ts myfile2.ts
-
+
deno fmt --check",
)
.arg(
@@ -669,7 +671,12 @@ fn fetch_subcommand<'a, 'b>() -> App<'a, 'b> {
.arg(importmap_arg())
.arg(config_arg())
.arg(no_remote_arg())
- .arg(Arg::with_name("file").takes_value(true).required(true))
+ .arg(
+ Arg::with_name("file")
+ .takes_value(true)
+ .required(true)
+ .min_values(1),
+ )
.about("Fetch the dependencies")
.long_about(
"Fetch and compile remote dependencies recursively.
@@ -1684,6 +1691,20 @@ mod tests {
}
#[test]
+ fn fetch_multiple() {
+ let r =
+ flags_from_vec_safe(svec!["deno", "fetch", "script.ts", "script_two.ts"]);
+ assert_eq!(
+ r.unwrap(),
+ DenoFlags {
+ subcommand: DenoSubcommand::Fetch,
+ argv: svec!["deno", "script.ts", "script_two.ts"],
+ ..DenoFlags::default()
+ }
+ );
+ }
+
+ #[test]
fn run_seed() {
let r =
flags_from_vec_safe(svec!["deno", "run", "--seed", "250", "script.ts"]);
diff --git a/cli/lib.rs b/cli/lib.rs
index 227dcdb40..42f5bbad1 100644
--- a/cli/lib.rs
+++ b/cli/lib.rs
@@ -303,6 +303,8 @@ async fn install_command(
}
async fn fetch_command(flags: DenoFlags) {
+ let args = flags.argv.clone();
+
let (mut worker, state) = create_worker_and_state(flags);
let main_module = state.main_module.as_ref().unwrap().clone();
@@ -313,6 +315,18 @@ async fn fetch_command(flags: DenoFlags) {
let result = worker.execute_mod_async(&main_module, None, true).await;
js_check(result);
+
+ // resolve modules for rest of args if present
+ let files_len = args.len();
+ if files_len > 2 {
+ for next_specifier in args.iter().take(files_len).skip(2) {
+ let next_module =
+ ModuleSpecifier::resolve_url_or_path(&next_specifier).unwrap();
+ let result = worker.execute_mod_async(&next_module, None, true).await;
+ js_check(result);
+ }
+ }
+
if state.flags.lock_write {
if let Some(ref lockfile) = state.lockfile {
let g = lockfile.lock().unwrap();
diff --git a/cli/tests/037_fetch_multiple.out b/cli/tests/037_fetch_multiple.out
new file mode 100644
index 000000000..cdb6fe2ba
--- /dev/null
+++ b/cli/tests/037_fetch_multiple.out
@@ -0,0 +1,5 @@
+Compile [WILDCARD]/fetch/test.ts
+Download http://localhost:4545/cli/tests/subdir/mod2.ts
+Download http://localhost:4545/cli/tests/subdir/print_hello.ts
+Compile [WILDCARD]/fetch/other.ts
+Download http://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts
diff --git a/cli/tests/fetch/other.ts b/cli/tests/fetch/other.ts
new file mode 100644
index 000000000..ab85b226f
--- /dev/null
+++ b/cli/tests/fetch/other.ts
@@ -0,0 +1 @@
+import "http://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts";
diff --git a/cli/tests/fetch/test.ts b/cli/tests/fetch/test.ts
new file mode 100644
index 000000000..1b49a76c8
--- /dev/null
+++ b/cli/tests/fetch/test.ts
@@ -0,0 +1 @@
+import "http://localhost:4545/cli/tests/subdir/mod2.ts";
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index fef69ad9e..b7dfc4e35 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -413,6 +413,13 @@ itest!(_036_import_map_fetch {
output: "036_import_map_fetch.out",
});
+itest!(_037_fetch_multiple {
+ args: "fetch --reload fetch/test.ts fetch/other.ts",
+ check_stderr: true,
+ http_server: true,
+ output: "037_fetch_multiple.out",
+});
+
itest!(_038_checkjs {
// checking if JS file is run through TS compiler
args: "run --reload --config 038_checkjs.tsconfig.json 038_checkjs.js",