(check: () => boolean, what: string, timeout = 20_000)
| 51 | const delay = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)); |
| 52 | |
| 53 | async function until(check: () => boolean, what: string, timeout = 20_000): Promise<void> { |
| 54 | const deadline = Date.now() + timeout; |
| 55 | while (!check()) { |
| 56 | if (Date.now() > deadline) throw new Error(`Timed out waiting for ${what}`); |
| 57 | await delay(25); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** Remove `dir` once nothing holds it: Windows can keep it busy a moment after a child exits. */ |
| 62 | async function removeWhenReleased(dir: string, timeoutMs = 5_000): Promise<void> { |
no test coverage detected