* 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)
| 773 | * no asynchronous initial-scan window with `fs.watch`. |
| 774 | */ |
| 775 | waitUntilReady(timeoutMs = 10000): Promise<void> { |
| 776 | if (this.ready) return Promise.resolve(); |
| 777 | return new Promise((resolve, reject) => { |
| 778 | const t = setTimeout(() => { |
| 779 | const idx = this.readyWaiters.indexOf(handler); |
| 780 | if (idx >= 0) this.readyWaiters.splice(idx, 1); |
| 781 | reject(new Error(`FileWatcher.waitUntilReady timed out after ${timeoutMs}ms`)); |
| 782 | }, timeoutMs); |
| 783 | const handler = () => { clearTimeout(t); resolve(); }; |
| 784 | this.readyWaiters.push(handler); |
| 785 | }); |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * Schedule a normal debounced sync after a source edit. |
no test coverage detected