diff --git a/test/fixtures/run-script/node_modules/.bin/path-env b/test/fixtures/run-script/node_modules/.bin/path-env new file mode 100755 index 00000000000000..88738a86701bd7 --- /dev/null +++ b/test/fixtures/run-script/node_modules/.bin/path-env @@ -0,0 +1,2 @@ +#!/bin/sh +echo "$PATH" diff --git a/test/fixtures/run-script/node_modules/.bin/path-env.bat b/test/fixtures/run-script/node_modules/.bin/path-env.bat new file mode 100644 index 00000000000000..11e37c63dec9ef --- /dev/null +++ b/test/fixtures/run-script/node_modules/.bin/path-env.bat @@ -0,0 +1,2 @@ +@shift +echo %PATH% diff --git a/test/fixtures/run-script/package.json b/test/fixtures/run-script/package.json index 79017b44450f96..822b753e3db61e 100644 --- a/test/fixtures/run-script/package.json +++ b/test/fixtures/run-script/package.json @@ -6,6 +6,8 @@ "positional-args": "positional-args", "positional-args-windows": "positional-args.bat", "custom-env": "custom-env", - "custom-env-windows": "custom-env.bat" + "custom-env-windows": "custom-env.bat", + "path-env": "path-env", + "path-env-windows": "path-env.bat" } } diff --git a/test/message/node_run_non_existent.out b/test/message/node_run_non_existent.out index 8d98465fa80606..a248a010a9b365 100644 --- a/test/message/node_run_non_existent.out +++ b/test/message/node_run_non_existent.out @@ -8,3 +8,5 @@ Available scripts are: positional-args-windows: positional-args.bat custom-env: custom-env custom-env-windows: custom-env.bat + path-env: path-env + path-env-windows: path-env.bat diff --git a/test/parallel/test-node-run.js b/test/parallel/test-node-run.js index ce0c21215fda58..69a7c9d9a46db1 100644 --- a/test/parallel/test-node-run.js +++ b/test/parallel/test-node-run.js @@ -64,4 +64,15 @@ describe('node run [command]', () => { assert.strictEqual(child.stderr, ''); assert.strictEqual(child.code, 0); }); + + it('should set PATH environment variable to node_modules/.bin', async () => { + const child = await common.spawnPromisified( + process.execPath, + [ '--no-warnings', '--run', `path-env${envSuffix}`], + { cwd: fixtures.path('run-script') }, + ); + assert.ok(child.stdout.includes(fixtures.path('run-script/node_modules/.bin'))); + assert.strictEqual(child.stderr, ''); + assert.strictEqual(child.code, 0); + }); });