(pid: number, timeoutMs = 3_000)
| 26 | } |
| 27 | |
| 28 | async function waitForProcessExit(pid: number, timeoutMs = 3_000): Promise<void> { |
| 29 | const deadline = Date.now() + timeoutMs; |
| 30 | while (true) { |
| 31 | try { |
| 32 | process.kill(pid, 0); |
| 33 | } catch (error) { |
| 34 | if ((error as NodeJS.ErrnoException).code === 'ESRCH') return; |
| 35 | throw error; |
| 36 | } |
| 37 | if (Date.now() >= deadline) throw new Error(`Detached descendant ${pid} is still running`); |
| 38 | await delay(20); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | function findPwsh(): string | undefined { |
| 43 | const exeNames = process.platform === 'win32' ? ['pwsh.exe'] : ['pwsh', 'pwsh-preview']; |
no test coverage detected