Skip to content

Commit

Permalink
Merge pull request #40 from roblg/fix-webpack-762
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 21, 2016
2 parents f121117 + a25f000 commit de3deda
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/DirectoryWatcher.js
Expand Up @@ -82,6 +82,8 @@ DirectoryWatcher.prototype.setFileTime = function setFileTime(filePath, mtime, i

this.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime];

ensureFsAccuracy(mtime);

// we add the fs accurency to reach the maximum possible mtime
if(mtime)
mtime = mtime + FS_ACCURENCY;
Expand Down Expand Up @@ -231,16 +233,7 @@ DirectoryWatcher.prototype.onChange = function onChange(filePath, stat) {
if(filePath.indexOf(this.path) !== 0) return;
if(/[\\\/]/.test(filePath.substr(this.path.length + 1))) return;
var mtime = +stat.mtime;
if(FS_ACCURENCY > 1 && mtime % 1 !== 0)
FS_ACCURENCY = 1;
else if(FS_ACCURENCY > 10 && mtime % 10 !== 0)
FS_ACCURENCY = 10;
else if(FS_ACCURENCY > 100 && mtime % 100 !== 0)
FS_ACCURENCY = 100;
else if(FS_ACCURENCY > 1000 && mtime % 1000 !== 0)
FS_ACCURENCY = 1000;
else if(FS_ACCURENCY > 2000 && mtime % 2000 !== 0)
FS_ACCURENCY = 2000;
ensureFsAccuracy(mtime);
this.setFileTime(filePath, mtime, false, "change");
};

Expand Down Expand Up @@ -333,3 +326,16 @@ DirectoryWatcher.prototype.close = function() {
}
this.emit("closed");
};

function ensureFsAccuracy(mtime) {
if(FS_ACCURENCY > 1 && mtime % 1 !== 0)
FS_ACCURENCY = 1;
else if(FS_ACCURENCY > 10 && mtime % 10 !== 0)
FS_ACCURENCY = 10;
else if(FS_ACCURENCY > 100 && mtime % 100 !== 0)
FS_ACCURENCY = 100;
else if(FS_ACCURENCY > 1000 && mtime % 1000 !== 0)
FS_ACCURENCY = 1000;
else if(FS_ACCURENCY > 2000 && mtime % 2000 !== 0)
FS_ACCURENCY = 2000;
}

0 comments on commit de3deda

Please sign in to comment.