diff options
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js | 4 | ||||
-rw-r--r-- | cli/tests/unit_node/child_process_test.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/internal/child_process.ts | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js b/cli/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js index 89a0860a3..2f6b41898 100644 --- a/cli/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js +++ b/cli/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js @@ -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}`); diff --git a/cli/tests/unit_node/child_process_test.ts b/cli/tests/unit_node/child_process_test.ts index d226319e6..d5d41125d 100644 --- a/cli/tests/unit_node/child_process_test.ts +++ b/cli/tests/unit_node/child_process_test.ts @@ -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); +}); diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts index 1c9aced19..04773a8b7 100644 --- a/ext/node/polyfills/internal/child_process.ts +++ b/ext/node/polyfills/internal/child_process.ts @@ -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"); |