(proc: ReturnType<typeof spawnWorker>)
| 89 | } |
| 90 | |
| 91 | async function stopWorker(proc: ReturnType<typeof spawnWorker>) { |
| 92 | if (proc.exitCode !== null || proc.signalCode !== null) return |
| 93 | |
| 94 | const closed = new Promise<void>((resolve) => proc.once("close", () => resolve())) |
| 95 | |
| 96 | if (process.platform !== "win32" || !proc.pid) { |
| 97 | proc.kill() |
| 98 | await closed |
| 99 | return |
| 100 | } |
| 101 | |
| 102 | await new Promise<void>((resolve) => { |
| 103 | const killProc = spawn("taskkill", ["/pid", String(proc.pid), "/T", "/F"]) |
| 104 | killProc.on("close", () => { |
| 105 | proc.kill() |
| 106 | resolve() |
| 107 | }) |
| 108 | }) |
| 109 | await closed |
| 110 | } |
| 111 | |
| 112 | async function readJson<T>(p: string): Promise<T> { |
| 113 | return JSON.parse(await fs.readFile(p, "utf8")) |
no test coverage detected