(pid: number)
| 13 | // Helper function to kill the complete process tree without leaving dev servers |
| 14 | // behind between Playwright runs. |
| 15 | async function killProcessTree(pid: number): Promise<void> { |
| 16 | if (process.platform === "win32") { |
| 17 | await new Promise<void>((resolve) => { |
| 18 | const taskkill = spawn("taskkill", ["/pid", pid.toString(), "/T", "/F"], { |
| 19 | stdio: "ignore", |
| 20 | }); |
| 21 | taskkill.once("close", () => resolve()); |
| 22 | taskkill.once("error", () => resolve()); |
| 23 | }); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | const processGroupExists = () => { |
| 28 | try { |
| 29 | process.kill(-pid, 0); |
| 30 | return true; |
| 31 | } catch { |
| 32 | return false; |
| 33 | } |
| 34 | }; |
| 35 | |
| 36 | try { |
| 37 | process.kill(-pid, "SIGTERM"); |
| 38 | } catch { |
| 39 | return; |
| 40 | } |
| 41 | for (let attempt = 0; attempt < 20 && processGroupExists(); attempt++) { |
| 42 | await new Promise((resolve) => setTimeout(resolve, 50)); |
| 43 | } |
| 44 | if (processGroupExists()) { |
| 45 | try { |
| 46 | process.kill(-pid, "SIGKILL"); |
| 47 | } catch { |
| 48 | // Process group exited between the liveness check and signal. |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | export interface Template { |
| 54 | name: string; |
no test coverage detected