(data: Buffer | string)
| 14 | constructor(private readonly prefix = '') {} |
| 15 | |
| 16 | handleData(data: Buffer | string): void { |
| 17 | const text = typeof data === 'string' ? data : this.decoder.write(data); |
| 18 | this.buffer += text; |
| 19 | |
| 20 | const carry = this.buffer.endsWith('\r') ? '\r' : ''; |
| 21 | const normalized = (carry ? this.buffer.slice(0, -1) : this.buffer).replace(/\r\n?/g, '\n'); |
| 22 | const lines = normalized.split('\n'); |
| 23 | this.buffer = (lines.pop() ?? '') + carry; |
| 24 | |
| 25 | for (const line of lines) { |
| 26 | this.logLine(line); |
| 27 | } |
| 28 | |
| 29 | if (this.buffer.length >= MAX_STDERR_BUFFER_LENGTH) { |
| 30 | this.logLine(this.buffer); |
| 31 | this.buffer = ''; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | flush(): void { |
| 36 | const remaining = this.buffer + this.decoder.end(); |
no test coverage detected