summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-24 19:35:43 -0500
committerGitHub <noreply@github.com>2023-02-24 19:35:43 -0500
commit033b70af19300a4e34dcf19ab0031245bfc19625 (patch)
treeebcd8e9ebd85a974c9845af0291ab3bdb9765704 /cli/tests
parent5683daf1aa1c01f5f4d01879d6ce054b0922faf6 (diff)
fix(npm): lazily install package.json dependencies only when necessary (#17931)
This lazily does an "npm install" when any package name matches what's found in the package.json or when running a script from package.json with deno task. Part of #17916 Closes #17928
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/npm_tests.rs4
-rw-r--r--cli/tests/integration/run_tests.rs8
-rw-r--r--cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out1
-rw-r--r--cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts1
-rw-r--r--cli/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js1
-rw-r--r--cli/tests/testdata/task/both/deno_selected.out2
-rw-r--r--cli/tests/testdata/task/both/prefers_deno.out2
7 files changed, 13 insertions, 6 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index 910936ac3..6a66db35f 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -1569,10 +1569,10 @@ itest!(create_require {
itest!(node_modules_import_run {
args: "run --quiet main.ts",
output: "npm/node_modules_import/main.out",
- envs: env_vars_for_npm_tests(),
http_server: true,
- cwd: Some("npm/node_modules_import/"),
copy_temp_dir: Some("npm/node_modules_import/"),
+ cwd: Some("npm/node_modules_import/"),
+ envs: env_vars_for_npm_tests(),
exit_code: 0,
});
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index c72fa5d9b..b60efc94d 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -2819,6 +2819,14 @@ itest!(package_json_auto_discovered_for_npm_binary {
http_server: true,
});
+itest!(package_json_auto_discovered_no_package_json_imports {
+ // this should not use --quiet because we should ensure no package.json install occurs
+ args: "run -A no_package_json_imports.ts",
+ output: "run/with_package_json/no_deno_json/no_package_json_imports.out",
+ cwd: Some("run/with_package_json/no_deno_json"),
+ copy_temp_dir: Some("run/with_package_json/no_deno_json"),
+});
+
itest!(package_json_with_deno_json {
args: "run --quiet -A main.ts",
output: "package_json/deno_json/main.out",
diff --git a/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out b/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out
new file mode 100644
index 000000000..7ed6ff82d
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out
@@ -0,0 +1 @@
+5
diff --git a/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts b/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts
new file mode 100644
index 000000000..0f3785f91
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts
@@ -0,0 +1 @@
+console.log(5);
diff --git a/cli/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js b/cli/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js
index 297653211..492a8fa40 100644
--- a/cli/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js
+++ b/cli/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js
@@ -1,2 +1,3 @@
+import "chalk";
console.log(Deno.cwd());
console.log(Deno.statSync("../node_modules"));
diff --git a/cli/tests/testdata/task/both/deno_selected.out b/cli/tests/testdata/task/both/deno_selected.out
index f55a74f5b..f5bbab26d 100644
--- a/cli/tests/testdata/task/both/deno_selected.out
+++ b/cli/tests/testdata/task/both/deno_selected.out
@@ -1,4 +1,2 @@
-Download http://localhost:4545/npm/registry/@denotest/bin
-Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
Task other deno eval 'console.log(2)'
2
diff --git a/cli/tests/testdata/task/both/prefers_deno.out b/cli/tests/testdata/task/both/prefers_deno.out
index cd6798e6d..391737272 100644
--- a/cli/tests/testdata/task/both/prefers_deno.out
+++ b/cli/tests/testdata/task/both/prefers_deno.out
@@ -1,4 +1,2 @@
-Download http://localhost:4545/npm/registry/@denotest/bin
-Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
Task output deno eval 'console.log(1)' "some" "text"
1