(event: FileChangeEvent, fileName: string)
| 277 | } |
| 278 | |
| 279 | function watchedFileChanged(event: FileChangeEvent, fileName: string) { |
| 280 | const normalizedPath = path.normalize(fileName); |
| 281 | |
| 282 | if ( |
| 283 | cachedOptions && |
| 284 | event === FileChangeEvent.Change && |
| 285 | // TODO(chuckj): validate that this is sufficient to skip files that were written. |
| 286 | // This assumes that the file path we write is the same file path we will receive in the |
| 287 | // change notification. |
| 288 | normalizedPath === path.normalize(cachedOptions.project) |
| 289 | ) { |
| 290 | // If the configuration file changes, forget everything and start the recompilation timer |
| 291 | resetOptions(); |
| 292 | } else if ( |
| 293 | event === FileChangeEvent.CreateDelete || |
| 294 | event === FileChangeEvent.CreateDeleteDir |
| 295 | ) { |
| 296 | // If a file was added or removed, reread the configuration |
| 297 | // to determine the new list of root files. |
| 298 | cachedOptions = undefined; |
| 299 | } |
| 300 | |
| 301 | if (event === FileChangeEvent.CreateDeleteDir) { |
| 302 | fileCache.clear(); |
| 303 | } else { |
| 304 | fileCache.delete(normalizedPath); |
| 305 | } |
| 306 | |
| 307 | if (!ignoreFilesForWatch.has(normalizedPath)) { |
| 308 | // Ignore the file if the file is one that was written by the compiler. |
| 309 | startTimerForRecompilation(normalizedPath); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // Upon detecting a file change, wait for 250ms and then perform a recompilation. This gives batch |
| 314 | // operations (such as saving all modified files in an editor) a chance to complete before we kick |
nothing calls this directly
no test coverage detected
searching dependent graphs…