| 284 | } |
| 285 | |
| 286 | private _watch(filePath: string, callback: () => MaybePromise<void>) { |
| 287 | let { watcher } = this; |
| 288 | if (!watcher) { |
| 289 | watcher = watch([]).on('all', (_event, path) => { |
| 290 | const callback = this.callbacks[path]; |
| 291 | callback?.(); |
| 292 | }); |
| 293 | this.watcher = watcher; |
| 294 | } |
| 295 | watcher.add(filePath); |
| 296 | this.callbacks[filePath] = sequence(callback); |
| 297 | return () => { |
| 298 | watcher.unwatch(filePath); |
| 299 | delete this.callbacks[filePath]; |
| 300 | }; |
| 301 | } |
| 302 | |
| 303 | addProvider(options?: { key?: string; filePath?: string }) { |
| 304 | const filePath = options?.filePath && resolve(options.filePath); |