MCPcopy Index your code
hub / github.com/angular/angular / watchedFileChanged

Function watchedFileChanged

packages/compiler-cli/src/perform_watch.ts:279–311  ·  view source on GitHub ↗
(event: FileChangeEvent, fileName: string)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

resetOptionsFunction · 0.85
normalizeMethod · 0.65
hasMethod · 0.65
clearMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…