Skip to content

Commit

Permalink
Handle files that are deleted and recreated
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Trevan Richins committed Sep 28, 2015
1 parent 3f5ec98 commit 92b1d6a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 92b1d6a

Please sign in to comment.