| 67 | } |
| 68 | |
| 69 | async function openBrowserWhenReady(url: string, timeoutMs = 120_000): Promise<void> { |
| 70 | const start = Date.now(); |
| 71 | while (Date.now() - start < timeoutMs) { |
| 72 | try { |
| 73 | const res = await fetch(url, { signal: AbortSignal.timeout(2000) }); |
| 74 | if (res.status < 500) { |
| 75 | openBrowser(url); |
| 76 | return; |
| 77 | } |
| 78 | } catch { |
| 79 | // not yet ready |
| 80 | } |
| 81 | await new Promise((r) => setTimeout(r, 2000)); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // Parses the top-level `volumes:` block of a docker-compose.yml and returns the |
| 86 | // declared volume names. Sufficient for our generated compose file; not a full |