Skip to content

Commit e8f0e1d

Browse files
committed
fix watching
1 parent 961ad40 commit e8f0e1d

File tree

5 files changed

+10
-95
lines changed

5 files changed

+10
-95
lines changed

lib/Cache.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

lib/Compiler.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
var clone = require("clone");
66
var Tapable = require("tapable");
77

8-
var Cache = require("./Cache");
9-
108
var Compilation = require("./Compilation");
119
var Parser = require("./Parser");
1210
var Resolver = require("enhanced-resolve/lib/Resolver");

lib/ContextModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ContextModule.prototype.readableIdentifier = function(requestShortener) {
5151
ContextModule.prototype.needRebuild = function(fileTimestamps, contextTimestamps) {
5252
var ts = contextTimestamps[this.context];
5353
if(!ts) return true;
54-
return ts > this.builtTime;
54+
return ts >= this.builtTime;
5555
};
5656

5757
ContextModule.prototype.disconnect = function disconnect() {

lib/NormalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ NormalModule.prototype.needRebuild = function needRebuild(fileTimestamps, contex
125125
if(!ts) timestamp = Infinity;
126126
if(ts > timestamp) timestamp = ts;
127127
});
128-
return timestamp > this.buildTimestamp;
128+
return timestamp >= this.buildTimestamp;
129129
};
130130

131131
NormalModule.prototype.size = function() {

lib/node/NodeWatchFileSystem.js

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ module.exports = NodeWatchFileSystem;
9292
* @param callbackUndelayed {function()} called once after first change
9393
*/
9494
NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, callback, callbackUndelayed) {
95+
var inputFileSystem = this.inputFileSystem;
96+
9597
if(!callbackUndelayed) callbackUndelayed = function() {}
9698
var closed = false;
9799
var fileTimestamps = {};
@@ -133,7 +135,7 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
133135
fs.stat(item.path, function(err, stat) {
134136
var ts = err ? Infinity : stat.mtime.getTime();
135137
fileTimestamps[item.path] = ts;
136-
if(ts > startTime) {
138+
if(ts >= startTime) {
137139
item.dirty = true;
138140
change();
139141
}
@@ -149,7 +151,7 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
149151
}
150152
traverse(item.path, files, function(ts) {
151153
if(item.type == 2) dirTimestamps[item.path] = ts;
152-
if(ts > startTime) {
154+
if(ts >= startTime) {
153155
item.dirty = true;
154156
change();
155157
}
@@ -184,7 +186,7 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
184186
// file
185187
var ts = stat.mtime.getTime();
186188
fileTimestamps[childItem.path] = ts;
187-
if(ts > startTime) {
189+
if(ts >= startTime) {
188190
childItem.dirty = true;
189191
}
190192
return callback(null, ts);
@@ -198,7 +200,7 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
198200
}
199201
traverse(thisPath, files, function(ts) {
200202
dirTimestamps[childItem.path] = ts;
201-
if(ts > startTime) {
203+
if(ts >= startTime) {
202204
childItem.dirty = true;
203205
}
204206
return callback(null, ts);
@@ -277,6 +279,7 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
277279
// 7.
278280
function onTimeout() {
279281
if(closed) return;
282+
if(inputFileSystem && inputFileSystem.purge) inputFileSystem.purge();
280283
callback(null, [], [], fileTimestamps, dirTimestamps);
281284

282285
close();
@@ -289,27 +292,8 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca
289292
});
290293
}
291294

292-
return;
293-
294-
setTimeout(function() {
295-
var fileTs = {};
296-
async.forEach(files, function(file, callback) {
297-
fs.stat(file, function(err, stat) {
298-
var ts = err ? Infinity : stat.mtime;
299-
fileTs[file] = ts;
300-
callback();
301-
});
302-
}, function(err) {
303-
if(closed) return;
304-
if(err) return callback(err);
305-
if(this.inputFileSystem.purge) this.inputFileSystem.purge();
306-
return callback(null, [], fileTs, {});
307-
}.bind(this));
308-
}.bind(this), 1000);
309295
return {
310-
close: function() {
311-
closed = true;
312-
}
296+
close: close
313297
}
314298
};
315299

0 commit comments

Comments
 (0)