(proc: ReturnType<typeof spawnWorker>)
| 67 | } |
| 68 | |
| 69 | async function stopWorker(proc: ReturnType<typeof spawnWorker>) { |
| 70 | if (proc.exitCode !== null || proc.signalCode !== null) return |
| 71 | |
| 72 | const closed = new Promise<void>((resolve) => proc.once("close", () => resolve())) |
| 73 | |
| 74 | if (process.platform !== "win32" || !proc.pid) { |
| 75 | proc.kill() |
| 76 | await closed |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | await new Promise<void>((resolve) => { |
| 81 | const killProc = spawn("taskkill", ["/pid", String(proc.pid), "/T", "/F"]) |
| 82 | killProc.on("close", () => { |
| 83 | proc.kill() |
| 84 | resolve() |
| 85 | }) |
| 86 | }) |
| 87 | await closed |
| 88 | } |
| 89 | |
| 90 | async function waitForFile(file: string, timeout = 3_000) { |
| 91 | const stop = Date.now() + timeout |
no test coverage detected