* Waits for a file to be created and populated.
(filePath: string)
| 68 | * Waits for a file to be created and populated. |
| 69 | */ |
| 70 | async function waitForFile(filePath: string): Promise<void> { |
| 71 | await waitFor(() => { |
| 72 | if (!fs.existsSync(filePath)) { |
| 73 | return false; |
| 74 | } |
| 75 | try { |
| 76 | return fs.statSync(filePath).size > 0; |
| 77 | } catch { |
| 78 | return false; |
| 79 | } |
| 80 | }, `Timeout: file ${filePath} not found within ${FILE_TIMEOUT}ms`); |
| 81 | } |
| 82 | |
| 83 | async function waitForDaemonReady(sessionId: string): Promise<void> { |
| 84 | const deadline = Date.now() + FILE_TIMEOUT; |
no test coverage detected