* 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)
| 700 | * no asynchronous initial-scan window with `fs.watch`. |
| 701 | */ |
| 702 | waitUntilReady(timeoutMs = 10000): Promise<void> { |
| 703 | if (this.ready) return Promise.resolve(); |
| 704 | return new Promise((resolve, reject) => { |
| 705 | const t = setTimeout(() => { |
| 706 | const idx = this.readyWaiters.indexOf(handler); |
| 707 | if (idx >= 0) this.readyWaiters.splice(idx, 1); |
| 708 | reject(new Error(`FileWatcher.waitUntilReady timed out after ${timeoutMs}ms`)); |
| 709 | }, timeoutMs); |
| 710 | const handler = () => { clearTimeout(t); resolve(); }; |
| 711 | this.readyWaiters.push(handler); |
| 712 | }); |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * Schedule a normal debounced sync after a source edit. |
no test coverage detected