Skip to content

Commit 54a9914

Browse files
committed
respect stdout/stderr output when requested
1 parent 2dd6769 commit 54a9914

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/core/process.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export async function execProcess(
104104
stdoutText = await processOutput(
105105
iterateReader(process.stdout),
106106
options.stdout,
107+
"stdout",
107108
);
108109
process.stdout.close();
109110
}
@@ -115,6 +116,7 @@ export async function execProcess(
115116
stderrText = await processOutput(
116117
iterator,
117118
options.stderr,
119+
"stderr",
118120
);
119121
process.stderr.close();
120122
}
@@ -161,12 +163,19 @@ function filteredAsyncIterator(
161163
async function processOutput(
162164
iterator: AsyncIterable<Uint8Array>,
163165
output?: "piped" | "inherit" | "null" | number,
166+
which?: "stdout" | "stderr",
164167
): Promise<string> {
165168
const decoder = new TextDecoder();
166169
let outputText = "";
167170
for await (const chunk of iterator) {
168171
if (output === "inherit" || output === undefined) {
169-
info(decoder.decode(chunk), { newline: false });
172+
if (which === "stdout") {
173+
Deno.stdout.writeSync(chunk);
174+
} else if (which === "stderr") {
175+
Deno.stderr.writeSync(chunk);
176+
} else {
177+
info(decoder.decode(chunk), { newline: false });
178+
}
170179
}
171180
const text = decoder.decode(chunk);
172181
outputText += text;

0 commit comments

Comments
 (0)