Skip to content

Commit 47ac984

Browse files
committed
Fix tests
1 parent c9cb492 commit 47ac984

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/arguments/options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {normalizeCwd} from './cwd.js';
1414
import {normalizeFileUrl} from './file-url.js';
1515
import {normalizeFdSpecificOptions} from './specific.js';
1616

17+
const cmdExeRegExp = /^cmd(?:\.exe)?$/i;
18+
1719
// Normalize the options object, and sometimes also the file paths and arguments.
1820
// Applies default values, validate allowed options, normalize them.
1921
export const normalizeOptions = (filePath, rawArguments, rawOptions) => {
@@ -37,7 +39,8 @@ export const normalizeOptions = (filePath, rawArguments, rawOptions) => {
3739
options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
3840
options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
3941

40-
if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
42+
// The file is now an absolute path resolved via `PATHEXT`, so its extension might be uppercase (`cmd.EXE`)
43+
if (process.platform === 'win32' && cmdExeRegExp.test(path.basename(file))) {
4144
// #116
4245
commandArguments.unshift('/q');
4346
}

test/terminate/timeout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ test('timeout kills the subprocess if it times out, in sync mode', async t => {
2121
t.true(isTerminated);
2222
t.is(signal, 'SIGTERM');
2323
t.true(timedOut);
24-
t.is(originalMessage, 'spawnSync node ETIMEDOUT');
24+
// On Windows, the command is spawned using the absolute path resolved via `PATHEXT`, so it appears in Node.js' own error message
25+
t.regex(originalMessage, /^spawnSync .*node(?:\.[A-Za-z]+)? ETIMEDOUT$/);
2526
t.is(shortMessage, `Command timed out after 1 milliseconds: node forever.js\n${originalMessage}`);
2627
t.is(message, shortMessage);
2728
});

0 commit comments

Comments
 (0)