refactor(stdio): always patch stdout and use createWorkingStdio for clean output (#14159)

This commit is contained in:
Allen Hutchison
2025-12-02 15:08:25 -08:00
committed by GitHub
parent 2d935b3798
commit 828afe113e
12 changed files with 31 additions and 24 deletions

View File

@@ -13,6 +13,11 @@ import stripAnsi from 'strip-ansi';
export class TextOutput {
private atStartOfLine = true;
private outputStream: NodeJS.WriteStream;
constructor(outputStream: NodeJS.WriteStream = process.stdout) {
this.outputStream = outputStream;
}
/**
* Writes a string to stdout.
@@ -22,7 +27,7 @@ export class TextOutput {
if (str.length === 0) {
return;
}
process.stdout.write(str);
this.outputStream.write(str);
const strippedStr = stripAnsi(str);
if (strippedStr.length > 0) {
this.atStartOfLine = strippedStr.endsWith('\n');