Skip to content

Commit 17ded87

Browse files
committed
test: fix spawnsync-shell to check correct options on Windows
This test expected to use cmd.exe options even if the shell was powershell. This commit fixes to check correct options for shells other than cmd.exe.
1 parent 6b779f8 commit 17ded87

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/child_process.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function normalizeSpawnArguments(file, args, options) {
450450

451451
// Validate windowsHide, if present.
452452
if (options.windowsHide != null &&
453-
typeof options.windowsHide !== 'boolean') {
453+
typeof options.windowsHide !== 'boolean') {
454454
throw new ERR_INVALID_ARG_TYPE('options.windowsHide',
455455
'boolean', options.windowsHide);
456456
}

test/parallel/test-child-process-spawnsync-shell.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ assert.strictEqual(env.stdout.toString().trim(), 'buzz');
5454

5555
function test(testPlatform, shell, shellOutput) {
5656
platform = testPlatform;
57-
57+
const isCmd = shellOutput.endsWith('cmd.exe') ||
58+
shellOutput.endsWith('cmd');
5859
const cmd = 'not_a_real_command';
59-
const shellFlags = platform === 'win32' ? ['/d', '/s', '/c'] : ['-c'];
60-
const outputCmd = platform === 'win32' ? `"${cmd}"` : cmd;
61-
const windowsVerbatim = platform === 'win32' ? true : undefined;
60+
61+
const shellFlags = isCmd ? ['/d', '/s', '/c'] : ['-c'];
62+
const outputCmd = isCmd ? `"${cmd}"` : cmd;
63+
const windowsVerbatim = isCmd ? true : undefined;
6264
internalCp.spawnSync = common.mustCall(function(opts) {
6365
assert.strictEqual(opts.file, shellOutput);
6466
assert.deepStrictEqual(opts.args,

0 commit comments

Comments
 (0)