Merge branch 'master' of github.com:zeit/next.js

This commit is contained in:
Guillermo Rauch 2016-12-31 11:43:16 -08:00
commit 8df45d0ba9

View file

@ -23,77 +23,10 @@ export default class WatchRemoveEventPlugin {
}, callbackUndelayed)
const watchpack = watchFileSystem.watcher
watchpack.fileWatchers.forEach((w) => {
w.on('remove', this.onRemove.bind(this, watchpack, w.path))
watchpack.on('remove', (file) => {
this.removedFiles.push(file)
})
return result
}
}
onRemove (watchpack, file) {
this.removedFiles.push(file)
watchpack.emit('remove', file)
watchpack._onChange(file)
}
}
// monkeypatching watchpack module to fix
// https://github.com/webpack/watchpack/pull/33
let DirectoryWatcher
try {
DirectoryWatcher = require('webpack/node_modules/watchpack/lib/DirectoryWatcher')
} catch (err) {
DirectoryWatcher = require('watchpack/lib/DirectoryWatcher')
}
/* eslint-disable */
var FS_ACCURENCY = 10000;
function withoutCase(str) {
return str.toLowerCase();
}
DirectoryWatcher.prototype.setFileTime = function setFileTime(filePath, mtime, initial, type) {
var now = Date.now();
var old = this.files[filePath];
this.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime];
// we add the fs accurency to reach the maximum possible mtime
if(mtime)
mtime = mtime + FS_ACCURENCY;
if(!old) {
if(mtime) {
if(this.watchers[withoutCase(filePath)]) {
this.watchers[withoutCase(filePath)].forEach(function(w) {
if(!initial || w.checkStartTime(mtime, initial)) {
w.emit("change", mtime);
}
});
}
}
} else if(!initial && mtime && type !== "add") {
if(this.watchers[withoutCase(filePath)]) {
this.watchers[withoutCase(filePath)].forEach(function(w) {
w.emit("change", mtime);
});
}
} else if(!initial && !mtime) {
delete this.files[filePath];
if(this.watchers[withoutCase(filePath)]) {
this.watchers[withoutCase(filePath)].forEach(function(w) {
w.emit("remove");
});
}
}
if(this.watchers[withoutCase(this.path)]) {
this.watchers[withoutCase(this.path)].forEach(function(w) {
if(!initial || w.checkStartTime(mtime, initial)) {
w.emit("change", filePath, mtime);
}
});
}
};
/* eslint-enable */