Skip to content

Commit

Permalink
test: add env variable test for --run
Browse files Browse the repository at this point in the history
PR-URL: #52811
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
anonrig authored and targos committed May 8, 2024
1 parent ad9c4bd commit 30a4248
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/fixtures/run-script/node_modules/.bin/path-env

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/fixtures/run-script/node_modules/.bin/path-env.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/fixtures/run-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 2 additions & 0 deletions test/message/node_run_non_existent.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions test/parallel/test-node-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 30a4248

Please sign in to comment.