mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(node/child_process): properly normalize stdio for 'spawnSync' (#21103)
Closes https://github.com/denoland/deno/issues/20782
This commit is contained in:
parent
9010b8df53
commit
612b7dfcc7
2 changed files with 22 additions and 3 deletions
|
@ -707,3 +707,17 @@ Deno.test(function spawnSyncUndefinedValueInEnvVar() {
|
||||||
assertEquals(ret.status, 0);
|
assertEquals(ret.status, 0);
|
||||||
assertEquals(ret.stdout.toString("utf-8").trim(), "BAZ");
|
assertEquals(ret.stdout.toString("utf-8").trim(), "BAZ");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test(function spawnSyncStdioUndefined() {
|
||||||
|
const ret = spawnSync(
|
||||||
|
`"${Deno.execPath()}" eval "console.log('hello');console.error('world')"`,
|
||||||
|
{
|
||||||
|
stdio: [undefined, undefined, undefined],
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(ret.status, 0);
|
||||||
|
assertEquals(ret.stdout.toString("utf-8").trim(), "hello");
|
||||||
|
assertEquals(ret.stderr.toString("utf-8").trim(), "world");
|
||||||
|
});
|
||||||
|
|
|
@ -835,7 +835,12 @@ export function spawnSync(
|
||||||
maxBuffer,
|
maxBuffer,
|
||||||
windowsVerbatimArguments = false,
|
windowsVerbatimArguments = false,
|
||||||
} = options;
|
} = options;
|
||||||
const normalizedStdio = normalizeStdioOption(stdio);
|
const [
|
||||||
|
_stdin_ = "pipe", // TODO(bartlomieju): use this?
|
||||||
|
stdout_ = "pipe",
|
||||||
|
stderr_ = "pipe",
|
||||||
|
_channel, // TODO(kt3k): handle this correctly
|
||||||
|
] = normalizeStdioOption(stdio);
|
||||||
[command, args] = buildCommand(command, args ?? [], shell);
|
[command, args] = buildCommand(command, args ?? [], shell);
|
||||||
|
|
||||||
const result: SpawnSyncResult = {};
|
const result: SpawnSyncResult = {};
|
||||||
|
@ -844,8 +849,8 @@ export function spawnSync(
|
||||||
args,
|
args,
|
||||||
cwd,
|
cwd,
|
||||||
env: mapValues(env, (value) => value.toString()),
|
env: mapValues(env, (value) => value.toString()),
|
||||||
stdout: toDenoStdio(normalizedStdio[1]),
|
stdout: toDenoStdio(stdout_),
|
||||||
stderr: toDenoStdio(normalizedStdio[2]),
|
stderr: toDenoStdio(stderr_),
|
||||||
uid,
|
uid,
|
||||||
gid,
|
gid,
|
||||||
windowsRawArguments: windowsVerbatimArguments,
|
windowsRawArguments: windowsVerbatimArguments,
|
||||||
|
|
Loading…
Reference in a new issue