(options: {
readonly stdoutError?: Error;
readonly stderrError?: Error;
readonly exitCode?: number;
} = {})
| 184 | } |
| 185 | |
| 186 | function processWithStreamError(options: { |
| 187 | readonly stdoutError?: Error; |
| 188 | readonly stderrError?: Error; |
| 189 | readonly exitCode?: number; |
| 190 | } = {}): KaosProcess { |
| 191 | const exitCode = options.exitCode ?? 0; |
| 192 | const stdout = new PassThrough(); |
| 193 | const stderr = new PassThrough(); |
| 194 | const waitPromise = new Promise<number>((resolve) => { |
| 195 | setTimeout(() => { |
| 196 | if (options.stdoutError !== undefined) { |
| 197 | stdout.emit('error', options.stdoutError); |
| 198 | } else { |
| 199 | stdout.end(); |
| 200 | } |
| 201 | if (options.stderrError !== undefined) { |
| 202 | stderr.emit('error', options.stderrError); |
| 203 | } else { |
| 204 | stderr.end(); |
| 205 | } |
| 206 | resolve(exitCode); |
| 207 | }, 1); |
| 208 | }); |
| 209 | return { |
| 210 | stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable, |
| 211 | stdout, |
| 212 | stderr, |
| 213 | pid: 128, |
| 214 | exitCode, |
| 215 | wait: vi.fn(async () => waitPromise), |
| 216 | kill: vi.fn(async () => {}), |
| 217 | dispose: vi.fn(async () => {}), |
| 218 | }; |
| 219 | } |
| 220 | |
| 221 | function processWithOpenStreamsThatExitOnKill(): KaosProcess { |
| 222 | let currentExitCode: number | null = null; |
no test coverage detected