summaryrefslogtreecommitdiff
path: root/tests/specs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-10-02 21:17:39 +0100
committerGitHub <noreply@github.com>2024-10-02 21:17:39 +0100
commitcac28b52621975137b86d4fd6efc32cecc10d682 (patch)
tree6338163b4be9d578dbe046a95c90cea274026b15 /tests/specs
parentbbd4ae1bc12dc6b34d4a455015096b7113a5cec5 (diff)
feat(byonm): support `deno run npm:<package>` when package is not in package.json (#25981)
Closes https://github.com/denoland/deno/issues/25905
Diffstat (limited to 'tests/specs')
-rw-r--r--tests/specs/npm/byonm_run_npm/__test__.jsonc30
-rw-r--r--tests/specs/npm/byonm_run_npm/deno.json2
-rw-r--r--tests/specs/npm/byonm_run_npm/not_in_deps.out8
-rw-r--r--tests/specs/npm/byonm_run_npm/overwrite.ts4
-rw-r--r--tests/specs/npm/byonm_run_npm/package.json4
5 files changed, 48 insertions, 0 deletions
diff --git a/tests/specs/npm/byonm_run_npm/__test__.jsonc b/tests/specs/npm/byonm_run_npm/__test__.jsonc
new file mode 100644
index 000000000..4f0b21b0f
--- /dev/null
+++ b/tests/specs/npm/byonm_run_npm/__test__.jsonc
@@ -0,0 +1,30 @@
+{
+ "tests": {
+ "not_in_deps": {
+ "steps": [{
+ "args": "run -A --quiet npm:cowsay moo",
+ "output": "not_in_deps.out"
+ }, {
+ // ensure it doesn't make any lockfile modifications and thus doesn't write to the lockfile
+ "args": [
+ "eval",
+ "try { Deno.statSync('deno.lock') } catch (e) { console.log(e instanceof Deno.errors.NotFound); }"
+ ],
+ "output": "true\n"
+ }]
+ },
+ "in_deps": {
+ "tempDir": true,
+ "steps": [{
+ "args": "install npm:cowsay",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-write overwrite.ts",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run -A npm:cowsay moo",
+ "output": "replaced\n"
+ }]
+ }
+ }
+}
diff --git a/tests/specs/npm/byonm_run_npm/deno.json b/tests/specs/npm/byonm_run_npm/deno.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/tests/specs/npm/byonm_run_npm/deno.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/specs/npm/byonm_run_npm/not_in_deps.out b/tests/specs/npm/byonm_run_npm/not_in_deps.out
new file mode 100644
index 000000000..dc07eb43e
--- /dev/null
+++ b/tests/specs/npm/byonm_run_npm/not_in_deps.out
@@ -0,0 +1,8 @@
+ _____
+< moo >
+ -----
+ \ ^__^
+ \ (oo)\_______
+ (__)\ )\/\
+ ||----w |
+ || ||
diff --git a/tests/specs/npm/byonm_run_npm/overwrite.ts b/tests/specs/npm/byonm_run_npm/overwrite.ts
new file mode 100644
index 000000000..3749c5e4e
--- /dev/null
+++ b/tests/specs/npm/byonm_run_npm/overwrite.ts
@@ -0,0 +1,4 @@
+Deno.writeTextFileSync(
+ "node_modules/cowsay/cli.js",
+ "console.log('replaced');",
+);
diff --git a/tests/specs/npm/byonm_run_npm/package.json b/tests/specs/npm/byonm_run_npm/package.json
new file mode 100644
index 000000000..9664f260a
--- /dev/null
+++ b/tests/specs/npm/byonm_run_npm/package.json
@@ -0,0 +1,4 @@
+{
+ "dependencies": {
+ }
+}