From 105d27bc7db5c0d2fd18cb26f41bd3193be74639 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 16 Aug 2024 12:48:48 +0900 Subject: fix(ext/node): improve shelljs compat with managed npm execution (#24912) This change improves the Node.js compatibility in managed npm resolution mode by disabling the discovery of `node_modules` when the main specifier is inside of `DENO_DIR`. closes #22732 closes #24589 --- tests/registry/npm/@denotest/exec-file/1.0.0/exec-child.js | 2 ++ tests/registry/npm/@denotest/exec-file/1.0.0/index.js | 6 ++++++ tests/registry/npm/@denotest/exec-file/1.0.0/package.json | 5 +++++ tests/specs/npm/exec_file_inside_npm_package/__test__.jsonc | 4 ++++ tests/specs/npm/exec_file_inside_npm_package/main.out | 1 + tests/specs/npm/exec_file_inside_npm_package/main.ts | 1 + tests/testdata/npm/exec_file/main.ts | 1 + 7 files changed, 20 insertions(+) create mode 100644 tests/registry/npm/@denotest/exec-file/1.0.0/exec-child.js create mode 100644 tests/registry/npm/@denotest/exec-file/1.0.0/index.js create mode 100644 tests/registry/npm/@denotest/exec-file/1.0.0/package.json create mode 100644 tests/specs/npm/exec_file_inside_npm_package/__test__.jsonc create mode 100644 tests/specs/npm/exec_file_inside_npm_package/main.out create mode 100644 tests/specs/npm/exec_file_inside_npm_package/main.ts create mode 100644 tests/testdata/npm/exec_file/main.ts (limited to 'tests') diff --git a/tests/registry/npm/@denotest/exec-file/1.0.0/exec-child.js b/tests/registry/npm/@denotest/exec-file/1.0.0/exec-child.js new file mode 100644 index 000000000..13ad51ca2 --- /dev/null +++ b/tests/registry/npm/@denotest/exec-file/1.0.0/exec-child.js @@ -0,0 +1,2 @@ +const { Buffer } = require("buffer"); +console.log(Buffer.from("Hello, world!").toString()); diff --git a/tests/registry/npm/@denotest/exec-file/1.0.0/index.js b/tests/registry/npm/@denotest/exec-file/1.0.0/index.js new file mode 100644 index 000000000..0129483aa --- /dev/null +++ b/tests/registry/npm/@denotest/exec-file/1.0.0/index.js @@ -0,0 +1,6 @@ +const child_process = require('child_process'); +const path = require('path'); + +const execArgs = [path.join(__dirname, "exec-child.js")] +const buf = child_process.execFileSync(process.execPath, execArgs); +console.log(buf.toString().trim()); diff --git a/tests/registry/npm/@denotest/exec-file/1.0.0/package.json b/tests/registry/npm/@denotest/exec-file/1.0.0/package.json new file mode 100644 index 000000000..50f013986 --- /dev/null +++ b/tests/registry/npm/@denotest/exec-file/1.0.0/package.json @@ -0,0 +1,5 @@ +{ + "name": "@denotest/exec-file", + "version": "1.0.0", + "main": "index.js" +} diff --git a/tests/specs/npm/exec_file_inside_npm_package/__test__.jsonc b/tests/specs/npm/exec_file_inside_npm_package/__test__.jsonc new file mode 100644 index 000000000..f816bad86 --- /dev/null +++ b/tests/specs/npm/exec_file_inside_npm_package/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run -A main.ts", + "output": "main.out" +} diff --git a/tests/specs/npm/exec_file_inside_npm_package/main.out b/tests/specs/npm/exec_file_inside_npm_package/main.out new file mode 100644 index 000000000..b0e5c237a --- /dev/null +++ b/tests/specs/npm/exec_file_inside_npm_package/main.out @@ -0,0 +1 @@ +[WILDCARD]Hello, world! diff --git a/tests/specs/npm/exec_file_inside_npm_package/main.ts b/tests/specs/npm/exec_file_inside_npm_package/main.ts new file mode 100644 index 000000000..8a90b3a34 --- /dev/null +++ b/tests/specs/npm/exec_file_inside_npm_package/main.ts @@ -0,0 +1 @@ +import "npm:@denotest/exec-file@1.0.0"; diff --git a/tests/testdata/npm/exec_file/main.ts b/tests/testdata/npm/exec_file/main.ts new file mode 100644 index 000000000..8a90b3a34 --- /dev/null +++ b/tests/testdata/npm/exec_file/main.ts @@ -0,0 +1 @@ +import "npm:@denotest/exec-file@1.0.0"; -- cgit v1.2.3