From 00b5fe8ba31240f6e6abf668ebda8ed0c40fb524 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 1 Aug 2023 18:47:57 -0400 Subject: feat(npm): support running non-bin scripts in npm pkgs via `deno run` (#19975) Closes https://github.com/denoland/deno/issues/19967 --- cli/tests/testdata/npm/deno_run_no_bin_entrypoint.out | 1 + .../testdata/npm/deno_run_no_bin_entrypoint_non_existent_subpath.out | 3 +++ cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli-cjs.js | 5 +++++ cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli.mjs | 5 +++++ cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/package.json | 4 ++++ 5 files changed, 18 insertions(+) create mode 100644 cli/tests/testdata/npm/deno_run_no_bin_entrypoint.out create mode 100644 cli/tests/testdata/npm/deno_run_no_bin_entrypoint_non_existent_subpath.out create mode 100644 cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli-cjs.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli.mjs create mode 100644 cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/package.json (limited to 'cli/tests/testdata/npm') diff --git a/cli/tests/testdata/npm/deno_run_no_bin_entrypoint.out b/cli/tests/testdata/npm/deno_run_no_bin_entrypoint.out new file mode 100644 index 000000000..b878bc70c --- /dev/null +++ b/cli/tests/testdata/npm/deno_run_no_bin_entrypoint.out @@ -0,0 +1 @@ +error: package '@denotest/esm-basic' did not have a bin property in its package.json diff --git a/cli/tests/testdata/npm/deno_run_no_bin_entrypoint_non_existent_subpath.out b/cli/tests/testdata/npm/deno_run_no_bin_entrypoint_non_existent_subpath.out new file mode 100644 index 000000000..06d7292b0 --- /dev/null +++ b/cli/tests/testdata/npm/deno_run_no_bin_entrypoint_non_existent_subpath.out @@ -0,0 +1,3 @@ +error: package '@denotest/esm-basic' did not have a bin property in its package.json + +Fallback failed: Cannot find module 'file:///[WILDCARD]/non-existent.js' diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli-cjs.js b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli-cjs.js new file mode 100644 index 000000000..7b6ba2724 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli-cjs.js @@ -0,0 +1,5 @@ +const process = require("process"); + +for (const arg of process.argv.slice(2)) { + console.log(arg); +} diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli.mjs b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli.mjs new file mode 100644 index 000000000..0ae8e9190 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/cli.mjs @@ -0,0 +1,5 @@ +import process from "node:process"; + +for (const arg of process.argv.slice(2)) { + console.log(arg); +} diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/package.json b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/package.json new file mode 100644 index 000000000..db50464bc --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.6.0/package.json @@ -0,0 +1,4 @@ +{ + "name": "@deno/bin", + "version": "0.6.0" +} -- cgit v1.2.3