* Adapter that turns a `FileSink` into the `Output` writer set. Both * `print` (line-oriented JSON) and `writeChunk` (raw bytes) flow into * the same stream; backpressure is preserved on the chunk path by * resolving the returned promise on `'drain'` when the kernel buffer * is full, mirroring t
(mode: OutputMode, sink: FileSink)
| 7806 | * is full, mirroring the stdout writer in `output.ts`. |
| 7807 | */ |
| 7808 | function makeFileOutput(mode: OutputMode, sink: FileSink): Output { |
| 7809 | return new Output(mode, { |
| 7810 | stdout: line => { |
| 7811 | sink.stream.write(`${line}\n`); |
| 7812 | }, |
| 7813 | rawStdout: text => { |
| 7814 | if (sink.error) throw sink.error; |
| 7815 | if (sink.stream.write(text)) return; |
| 7816 | return new Promise<void>(resolve => { |
| 7817 | sink.stream.once('drain', () => resolve()); |
| 7818 | }); |
| 7819 | }, |
| 7820 | }); |
| 7821 | } |
| 7822 | |
| 7823 | /** |
| 7824 | * Flush + close the file sink. Called on the success path after the |