Skip to content

Commit

Permalink
Merge pull request #33 from nkzawa/fix/remove-event
Browse files Browse the repository at this point in the history
Fix remove event is not emitted
  • Loading branch information
sokra authored Dec 14, 2016
2 parents d9b0dbc + 0232e01 commit 16b2a0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ DirectoryWatcher.prototype.setFileTime = function setFileTime(filePath, mtime, i
this.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime];

// we add the fs accurency to reach the maximum possible mtime
mtime = mtime + FS_ACCURENCY;
if(mtime)
mtime = mtime + FS_ACCURENCY;

if(!old) {
if(mtime) {
Expand Down
14 changes: 14 additions & 0 deletions test/DirectoryWatcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,18 @@ describe("DirectoryWatcher", function() {
});
});
});

it("should detect a file removal", function(done) {
testHelper.file("a");
var d = new DirectoryWatcher(fixtures, {});
var a = d.watch(path.join(fixtures, "a"));
a.on("remove", function(mtime) {
(typeof mtime === 'undefined').should.be.true;
a.close();
done();
});
testHelper.tick(function() {
testHelper.remove("a");
});
});
});

0 comments on commit 16b2a0e

Please sign in to comment.