(vc: CLIProcess)
| 33 | } |
| 34 | |
| 35 | async function getLocalhost(vc: CLIProcess): Promise<RegExpExecArray> { |
| 36 | let localhost: RegExpExecArray | undefined; |
| 37 | await waitForPrompt( |
| 38 | vc, |
| 39 | chunk => { |
| 40 | const line = chunk.toString(); |
| 41 | if (line.includes('Ready! Available at')) { |
| 42 | localhost = /(https?:[^\s]+)/g.exec(line) || undefined; |
| 43 | return true; |
| 44 | } |
| 45 | return false; |
| 46 | }, |
| 47 | 5000 |
| 48 | ); |
| 49 | |
| 50 | // This should never happen because waitForPrompt will time out |
| 51 | // and never return here in this case, but extra checking is fine |
| 52 | // and it makes typescript happy |
| 53 | if (!localhost) { |
| 54 | throw new Error('Localhost not found!'); |
| 55 | } |
| 56 | |
| 57 | return localhost; |
| 58 | } |
| 59 | |
| 60 | beforeAll(async () => { |
| 61 | try { |
no test coverage detected