(child: ChildProcess)
| 828 | } |
| 829 | |
| 830 | function captureChildOutput(child: ChildProcess): () => string { |
| 831 | const chunks: string[] = []; |
| 832 | const append = (source: string, chunk: Buffer) => { |
| 833 | chunks.push(`[${source}] ${chunk.toString("utf8")}`); |
| 834 | while (chunks.join("").length > 16_384) { |
| 835 | chunks.shift(); |
| 836 | } |
| 837 | }; |
| 838 | child.stdout?.on("data", (chunk: Buffer) => append("stdout", chunk)); |
| 839 | child.stderr?.on("data", (chunk: Buffer) => append("stderr", chunk)); |
| 840 | return () => chunks.join("").trim(); |
| 841 | } |
| 842 | |
| 843 | async function freePortPair(): Promise<number> { |
| 844 | for (let attempt = 0; attempt < 100; attempt += 1) { |
no test coverage detected