From 92b1d6af066dcf98cc0f5bcb1f8410ad492400f3 Mon Sep 17 00:00:00 2001 From: Trevan Richins Date: Mon, 28 Sep 2015 12:37:47 -0600 Subject: [PATCH] Handle files that are deleted and recreated If vim is set up to use a swap file, then when a save is changed, it deletes the original file and renames the swap file into place. This can sometimes cause chokidar to send two events: "remove" and "add". Because the DirectoryWatcher doesn't clear out removed files, the subsequent add event is ignored and the change is not seen. --- lib/DirectoryWatcher.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/DirectoryWatcher.js b/lib/DirectoryWatcher.js index ce141e5..e38113d 100644 --- a/lib/DirectoryWatcher.js +++ b/lib/DirectoryWatcher.js @@ -95,6 +95,7 @@ DirectoryWatcher.prototype.setFileTime = function setFileTime(filePath, mtime, i }); } } else if(!initial && !mtime) { + delete this.files[filePath]; if(this.watchers[withoutCase(filePath)]) { this.watchers[withoutCase(filePath)].forEach(function(w) { w.emit("remove");