| 51 | }; |
| 52 | |
| 53 | const stopTree = async (child: ChildProcess): Promise<void> => { |
| 54 | if (child.pid === undefined || child.exitCode !== null) return; |
| 55 | try { |
| 56 | process.kill(-child.pid, "SIGTERM"); |
| 57 | } catch { |
| 58 | child.kill("SIGTERM"); |
| 59 | } |
| 60 | await Promise.race([ |
| 61 | new Promise((resolve) => child.once("exit", resolve)), |
| 62 | new Promise((resolve) => setTimeout(resolve, 5_000)), |
| 63 | ]); |
| 64 | if (child.exitCode === null) { |
| 65 | try { |
| 66 | process.kill(-child.pid, "SIGKILL"); |
| 67 | } catch { |
| 68 | child.kill("SIGKILL"); |
| 69 | } |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | interface ViteDev { |
| 74 | readonly origin: string; |