0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(node): spawnSync's status was incorrect (#21359)

The exit code wasn't hooked up properly.
This commit is contained in:
David Sherret 2023-11-27 19:54:01 -05:00 committed by GitHub
parent d65a297943
commit d4ef471744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -5,7 +5,7 @@
// Taken from Node 18.8.0
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
// TODO(cjihrig): 'run -A require.ts' should not be needed in
// TODO(cjihrig): 'run -A runner.ts' should not be needed in
// execSync() call at the bottom of this test.
'use strict';
@ -49,4 +49,4 @@ setTimeout(() => {
}, 100);
`);
execSync(`${process.argv[0]} run -A require.ts ${tmpJsFile} < ${tmpCmdFile}`);
execSync(`${process.argv[0]} run -A runner.ts ${tmpJsFile} < ${tmpCmdFile}`);

View file

@ -722,3 +722,12 @@ Deno.test(function spawnSyncStdioUndefined() {
assertEquals(ret.stdout.toString("utf-8").trim(), "hello");
assertEquals(ret.stderr.toString("utf-8").trim(), "world");
});
Deno.test(function spawnSyncExitNonZero() {
const ret = spawnSync(
`"${Deno.execPath()}" eval "Deno.exit(22)"`,
{ shell: true },
);
assertEquals(ret.status, 22);
});

View file

@ -855,7 +855,7 @@ export function spawnSync(
windowsRawArguments: windowsVerbatimArguments,
}).outputSync();
const status = output.signal ? null : 0;
const status = output.signal ? null : output.code;
let stdout = parseSpawnSyncOutputStreams(output, "stdout");
let stderr = parseSpawnSyncOutputStreams(output, "stderr");