(child: ReturnType<typeof spawn>)
| 140 | } |
| 141 | |
| 142 | async function stopChild(child: ReturnType<typeof spawn>) { |
| 143 | if (child.killed || child.exitCode !== null) { |
| 144 | return |
| 145 | } |
| 146 | |
| 147 | const killTree = (signal: NodeJS.Signals) => { |
| 148 | if (typeof child.pid === 'number') { |
| 149 | try { |
| 150 | process.kill(-child.pid, signal) |
| 151 | return |
| 152 | } catch { |
| 153 | // fall through to direct child kill |
| 154 | } |
| 155 | } |
| 156 | child.kill(signal) |
| 157 | } |
| 158 | |
| 159 | killTree('SIGTERM') |
| 160 | |
| 161 | await new Promise<void>((resolvePromise) => { |
| 162 | const timer = setTimeout(() => { |
| 163 | if (!child.killed && child.exitCode === null) { |
| 164 | killTree('SIGKILL') |
| 165 | } |
| 166 | resolvePromise() |
| 167 | }, 5_000) |
| 168 | |
| 169 | child.once('close', () => { |
| 170 | clearTimeout(timer) |
| 171 | resolvePromise() |
| 172 | }) |
| 173 | }) |
| 174 | } |
| 175 | |
| 176 | async function patchViteConfigForE2E(appDir: string) { |
| 177 | const viteConfigPath = join(appDir, 'vite.config.ts') |
no test coverage detected