Skip to content

Commit

Permalink
fix(internal): Exempt process.stdout from being closed by makeFsStrea…
Browse files Browse the repository at this point in the history
…mWriter
  • Loading branch information
gibson042 committed Mar 1, 2025
1 parent 5552c3c commit fe7d415
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/internal/src/node/fs-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ export const makeFsStreamWriter = async filePath => {
return undefined;
}

const useStdout = filePath === '-';
const { handle, stream } = await (async () => {
if (filePath === '-') {
if (useStdout) {
return { handle: undefined, stream: process.stdout };
}
const fh = await open(filePath, 'a');
return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
})();
await fsStreamReady(stream);
const writeAsync = promisify(stream.write.bind(stream));
const endAsync = stream.end && promisify(stream.end.bind(stream));
const endAsync = useStdout
? undefined
: stream.end && promisify(stream.end.bind(stream));

let flushed = Promise.resolve();
let closed = false;
Expand Down

0 comments on commit fe7d415

Please # to comment.