(stream: NodeJS.ReadableStream | null, isStderr: boolean)
| 198 | }; |
| 199 | |
| 200 | const processStream = (stream: NodeJS.ReadableStream | null, isStderr: boolean) => { |
| 201 | if (!stream) { |
| 202 | markDone(); |
| 203 | return; |
| 204 | } |
| 205 | let buffer = ""; |
| 206 | stream.on("data", (chunk: Buffer) => { |
| 207 | buffer += chunk.toString(); |
| 208 | const parts = buffer.split("\n"); |
| 209 | buffer = parts.pop() ?? ""; |
| 210 | for (const line of parts) { |
| 211 | const trimmed = line.trim(); |
| 212 | if (trimmed) { |
| 213 | pushLine(trimmed); |
| 214 | if (isStderr) stderrLines.push(trimmed); |
| 215 | } |
| 216 | } |
| 217 | }); |
| 218 | stream.on("end", () => { |
| 219 | if (buffer.trim()) { |
| 220 | pushLine(buffer.trim()); |
| 221 | if (isStderr) stderrLines.push(buffer.trim()); |
| 222 | } |
| 223 | markDone(); |
| 224 | }); |
| 225 | stream.on("error", markDone); |
| 226 | }; |
| 227 | |
| 228 | processStream(child.stdout, false); |
| 229 | processStream(child.stderr, true); |
no test coverage detected