File tree Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -697,9 +697,39 @@ export class Watcher {
697
697
}
698
698
}
699
699
700
- // Given a WatchSet, returns true if it currently describes the state of the
701
- // disk.
702
- export function isUpToDate ( watchSet ) {
700
+ // Given a WatchSet, returns true if it currently describes the state of
701
+ // the disk. If mtimeWindowMs is a number, return true if none of the
702
+ // watched files were touched since that many milliseconds ago.
703
+ export function isUpToDate ( watchSet , mtimeWindowMs ) {
704
+ if ( typeof mtimeWindowMs === "number" ) {
705
+ const now = + new Date ;
706
+ let recentlyChanged = false ;
707
+
708
+ for ( var file in watchSet . files ) {
709
+ var stat = files . statOrNull ( file ) ;
710
+ var hash = watchSet . files [ file ] ;
711
+
712
+ if ( typeof hash === "string" ) {
713
+ if ( ! stat || stat . isDirectory ( ) ) {
714
+ recentlyChanged = true ;
715
+ break ;
716
+ }
717
+ } else if ( stat ) {
718
+ recentlyChanged = true ;
719
+ break ;
720
+ }
721
+
722
+ if ( stat && ( now - stat . mtime < mtimeWindowMs ) ) {
723
+ recentlyChanged = true ;
724
+ break ;
725
+ }
726
+ }
727
+
728
+ if ( ! recentlyChanged ) {
729
+ return true ;
730
+ }
731
+ }
732
+
703
733
return Profile . time ( 'watch.isUpToDate' , ( ) => {
704
734
var upToDate = true ;
705
735
var watcher = new Watcher ( {
Original file line number Diff line number Diff line change @@ -410,7 +410,11 @@ _.extend(exports.IsopackCache.prototype, {
410
410
// Merge in the watchsets for all unibuilds and plugins in the package, then
411
411
// check it once.
412
412
var watchSet = previousIsopack . getMergedWatchSet ( ) ;
413
- return watch . isUpToDate ( watchSet ) ;
413
+
414
+ // Since we've checked this isopack previously, take a shortcut by not
415
+ // considering it out of date unless any of its files have mtimes
416
+ // within the last 30 seconds.
417
+ return watch . isUpToDate ( watchSet , 30 * 1000 ) ;
414
418
} ,
415
419
416
420
_isopackDir : function ( packageName ) {
You can’t perform that action at this time.
0 commit comments