(chunk: Buffer)
| 391 | } |
| 392 | |
| 393 | const scanStdoutForTerminalResult = (chunk: Buffer): void => { |
| 394 | if (opts.terminalJsonResultGraceMs === undefined || terminalResultExitCode !== undefined) |
| 395 | return; |
| 396 | stdoutBuffer += chunk.toString('utf8'); |
| 397 | const lines = stdoutBuffer.split('\n'); |
| 398 | stdoutBuffer = lines.pop() ?? ''; |
| 399 | for (const line of lines) { |
| 400 | if (line.trim().length === 0) continue; |
| 401 | try { |
| 402 | const record = JSON.parse(line) as StreamJsonResult; |
| 403 | if (record.type === 'result') recordTerminalResult(record); |
| 404 | } catch { |
| 405 | // Claude stream-json records are newline-delimited JSON. Ignore non-JSON fragments. |
| 406 | } |
| 407 | } |
| 408 | }; |
| 409 | |
| 410 | child.stdout.on('data', (chunk: Buffer) => { |
| 411 | if (settled) return; |
no test coverage detected