summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/run/with_package_json/with_stop
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/testdata/run/with_package_json/with_stop
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/testdata/run/with_package_json/with_stop')
-rw-r--r--cli/tests/testdata/run/with_package_json/with_stop/main.out4
-rw-r--r--cli/tests/testdata/run/with_package_json/with_stop/package.json8
-rw-r--r--cli/tests/testdata/run/with_package_json/with_stop/some/nested/deno.json5
-rw-r--r--cli/tests/testdata/run/with_package_json/with_stop/some/nested/dir/main.ts6
4 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/with_package_json/with_stop/main.out b/cli/tests/testdata/run/with_package_json/with_stop/main.out
new file mode 100644
index 000000000..e7ef053e4
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/with_stop/main.out
@@ -0,0 +1,4 @@
+[WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json'
+[WILDCARD]No package.json file found
+[WILDCARD]
+ok
diff --git a/cli/tests/testdata/run/with_package_json/with_stop/package.json b/cli/tests/testdata/run/with_package_json/with_stop/package.json
new file mode 100644
index 000000000..9ee3f39a8
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/with_stop/package.json
@@ -0,0 +1,8 @@
+{
+ "dependencies": {
+ "@denotest/check-error": "1.0.0"
+ },
+ "devDependencies": {
+ "@denotest/cjs-default-export": "1.0.0"
+ }
+}
diff --git a/cli/tests/testdata/run/with_package_json/with_stop/some/nested/deno.json b/cli/tests/testdata/run/with_package_json/with_stop/some/nested/deno.json
new file mode 100644
index 000000000..36e1765d1
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/with_stop/some/nested/deno.json
@@ -0,0 +1,5 @@
+{
+ "tasks": {
+ "dev": "deno run main.ts"
+ }
+}
diff --git a/cli/tests/testdata/run/with_package_json/with_stop/some/nested/dir/main.ts b/cli/tests/testdata/run/with_package_json/with_stop/some/nested/dir/main.ts
new file mode 100644
index 000000000..daefa8f60
--- /dev/null
+++ b/cli/tests/testdata/run/with_package_json/with_stop/some/nested/dir/main.ts
@@ -0,0 +1,6 @@
+// TODO(bartlomieju): currently we don't support actual bare specifier
+// imports; this will be done in a follow up PR.
+// import express from "express";
+
+// console.log(express);
+console.log("ok");