( path: string, event: 'change' | 'add' | 'unlink', )
| 78 | } |
| 79 | |
| 80 | function handleFileEvent( |
| 81 | path: string, |
| 82 | event: 'change' | 'add' | 'unlink', |
| 83 | ): void { |
| 84 | logForDebugging(`FileChanged: ${event} ${path}`) |
| 85 | void executeFileChangedHooks(path, event) |
| 86 | .then(({ results, watchPaths, systemMessages }) => { |
| 87 | if (watchPaths.length > 0) { |
| 88 | updateWatchPaths(watchPaths) |
| 89 | } |
| 90 | for (const msg of systemMessages) { |
| 91 | notifyCallback?.(msg, false) |
| 92 | } |
| 93 | for (const r of results) { |
| 94 | if (!r.succeeded && r.output) { |
| 95 | notifyCallback?.(r.output, true) |
| 96 | } |
| 97 | } |
| 98 | }) |
| 99 | .catch(e => { |
| 100 | const msg = errorMessage(e) |
| 101 | logForDebugging(`FileChanged hook failed: ${msg}`, { |
| 102 | level: 'error', |
| 103 | }) |
| 104 | notifyCallback?.(msg, true) |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | export function updateWatchPaths(paths: string[]): void { |
| 109 | if (!initialized) return |
no test coverage detected