@@ -92,6 +92,8 @@ module.exports = NodeWatchFileSystem;
9292 * @param callbackUndelayed {function()} called once after first change
9393 */
9494NodeWatchFileSystem . 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