From cdf5b419f84a8a54aed1dbd47068ffa07ea00cfd Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 13 Mar 2018 15:09:13 -0700 Subject: [PATCH] Do not send first missing file event as well. --- src/compiler/sys.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index f613a2fc927..e3c304afb8f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -752,12 +752,17 @@ namespace ts { }; function fileChanged(curr: any, prev: any) { + // previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears) + // In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation + const isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted; if (+curr.mtime === 0) { + if (isPreviouslyDeleted) { + // Already deleted file, no need to callback again + return; + } eventKind = FileWatcherEventKind.Deleted; } - // previous event kind check is to ensure we send created event when file is restored or renamed twice (that is it disappears and reappears) - // since in that case the prevTime returned is same as prev time of event when file was deleted as per node documentation - else if (+prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted) { + else if (isPreviouslyDeleted) { eventKind = FileWatcherEventKind.Created; } // If there is no change in modified time, ignore the event