* Resolves once the watch set has been installed (or immediately if it * already has). Useful for tests that need a deterministic boundary before * asserting on `pendingFiles`. * * Production callers don't need this: `pendingFiles` is read continuously, * the staleness banner is alway
(timeoutMs = 10000)
| 1015 | * no asynchronous initial-scan window with `fs.watch`. |
| 1016 | */ |
| 1017 | waitUntilReady(timeoutMs = 10000): Promise<void> { |
| 1018 | if (this.ready) return Promise.resolve(); |
| 1019 | return new Promise((resolve, reject) => { |
| 1020 | const t = setTimeout(() => { |
| 1021 | const idx = this.readyWaiters.indexOf(handler); |
| 1022 | if (idx >= 0) this.readyWaiters.splice(idx, 1); |
| 1023 | reject(new Error(`FileWatcher.waitUntilReady timed out after ${timeoutMs}ms`)); |
| 1024 | }, timeoutMs); |
| 1025 | const handler = () => { clearTimeout(t); resolve(); }; |
| 1026 | this.readyWaiters.push(handler); |
| 1027 | }); |
| 1028 | } |
| 1029 | |
| 1030 | /** |
| 1031 | * Schedule a normal debounced sync after a source edit. |
no test coverage detected