mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
fix(ext/node): handle null
in stdio array (#23048)
Fixes https://github.com/denoland/deno/issues/23045
This commit is contained in:
parent
c940205353
commit
ec9342f95a
2 changed files with 23 additions and 1 deletions
|
@ -503,11 +503,20 @@ function normalizeStdioOption(
|
|||
if (Array.isArray(stdio)) {
|
||||
// `[0, 1, 2]` is equivalent to `"inherit"`
|
||||
if (
|
||||
stdio.length === 3 && stdio[0] === 0 && stdio[1] === 1 && stdio[2] === 2
|
||||
stdio.length === 3 &&
|
||||
(stdio[0] === 0 && stdio[1] === 1 && stdio[2] === 2)
|
||||
) {
|
||||
return ["inherit", "inherit", "inherit"];
|
||||
}
|
||||
|
||||
// `[null, null, null]` is equivalent to `"pipe"
|
||||
if (
|
||||
stdio.length === 3 &&
|
||||
stdio[0] === null || stdio[1] === null || stdio[2] === null
|
||||
) {
|
||||
return ["pipe", "pipe", "pipe"];
|
||||
}
|
||||
|
||||
// At least 3 stdio must be created to match node
|
||||
while (stdio.length < 3) {
|
||||
ArrayPrototypePush(stdio, undefined);
|
||||
|
|
|
@ -810,3 +810,16 @@ Deno.test(async function spawnCommandNotFoundErrno() {
|
|||
});
|
||||
await promise;
|
||||
});
|
||||
|
||||
// https://github.com/denoland/deno/issues/23045
|
||||
Deno.test(function spawnCommandNullStdioArray() {
|
||||
const ret = spawnSync(
|
||||
`"${Deno.execPath()}" eval "console.log('hello');console.error('world')"`,
|
||||
{
|
||||
stdio: [null, null, null],
|
||||
shell: true,
|
||||
},
|
||||
);
|
||||
|
||||
assertEquals(ret.status, 0);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue