From cac28b52621975137b86d4fd6efc32cecc10d682 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 2 Oct 2024 21:17:39 +0100 Subject: feat(byonm): support `deno run npm:` when package is not in package.json (#25981) Closes https://github.com/denoland/deno/issues/25905 --- tests/specs/npm/byonm_run_npm/__test__.jsonc | 30 +++++++++++++++++++++++++++ tests/specs/npm/byonm_run_npm/deno.json | 2 ++ tests/specs/npm/byonm_run_npm/not_in_deps.out | 8 +++++++ tests/specs/npm/byonm_run_npm/overwrite.ts | 4 ++++ tests/specs/npm/byonm_run_npm/package.json | 4 ++++ 5 files changed, 48 insertions(+) create mode 100644 tests/specs/npm/byonm_run_npm/__test__.jsonc create mode 100644 tests/specs/npm/byonm_run_npm/deno.json create mode 100644 tests/specs/npm/byonm_run_npm/not_in_deps.out create mode 100644 tests/specs/npm/byonm_run_npm/overwrite.ts create mode 100644 tests/specs/npm/byonm_run_npm/package.json (limited to 'tests/specs') 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": { + } +} -- cgit v1.2.3