summaryrefslogtreecommitdiff
path: root/cli/tests/integration/run_tests.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-02-20 19:14:06 +0100
committerGitHub <noreply@github.com>2023-02-20 19:14:06 +0100
commit4d1a14ca7fa9496f36470a7771448a9b006b0204 (patch)
treede226f6368faec98065bf14382f23541484cfe72 /cli/tests/integration/run_tests.rs
parent88f6fc6a1684326ae1f947ea8ec24ad0bff0f449 (diff)
feat: auto-discover package.json for npm dependencies (#17272)
This commits adds auto-discovery of "package.json" file when running "deno run" and "deno task" subcommands. In case of "deno run" the "package.json" is being looked up starting from the directory of the script that is being run, stopping early if "deno.json(c)" file is found (ie. FS tree won't be traversed "up" from "deno.json"). When "package.json" is discovered the "--node-modules-dir" flag is implied, leading to creation of local "node_modules/" directory - we did that, because most tools relying on "package.json" will expect "node_modules/" directory to be present (eg. Vite). Additionally "dependencies" and "devDependencies" specified in the "package.json" are downloaded on startup. This is a stepping stone to supporting bare specifier imports, but the actual integration will be done in a follow up commit. --------- Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tests/integration/run_tests.rs')
-rw-r--r--cli/tests/integration/run_tests.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 02fa5c2a0..6a436c318 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -2693,6 +2693,34 @@ itest!(config_not_auto_discovered_for_remote_script {
http_server: true,
});
+itest!(package_json_auto_discovered_for_local_script_log {
+ args: "run -L debug no_deno_json/main.ts",
+ output: "run/with_package_json/no_deno_json/main.out",
+ maybe_cwd: Some("run/with_package_json/"),
+ envs: env_vars_for_npm_tests_no_sync_download(),
+ http_server: true,
+});
+
+// In this case we shouldn't discover `package.json` file, because it's in a
+// directory that is above the directory containing `deno.json` file.
+itest!(
+ package_json_auto_discovered_for_local_script_log_with_stop {
+ args: "run -L debug with_stop/some/nested/dir/main.ts",
+ output: "run/with_package_json/with_stop/main.out",
+ maybe_cwd: Some("run/with_package_json/"),
+ envs: env_vars_for_npm_tests_no_sync_download(),
+ http_server: true,
+ }
+);
+
+itest!(package_json_auto_discovered_for_npm_binary {
+ args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test",
+ output: "run/with_package_json/npm_binary/main.out",
+ maybe_cwd: Some("run/with_package_json/npm_binary/"),
+ envs: env_vars_for_npm_tests_no_sync_download(),
+ http_server: true,
+});
+
itest!(wasm_streaming_panic_test {
args: "run run/wasm_streaming_panic_test.js",
output: "run/wasm_streaming_panic_test.js.out",