In a year...
Using
- nodejs 0.10.25
- gulp 3.8.10
The Gaz debounceDelay function did not change anything for me, and I did not understand how to use the gulp -Batch callback argument :/ ...
To avoid calling tasks with a sequence after several files have been changed, I used the oldschool setTimeout function:
// ... var SRC = ['js/*.js', '!js/*.min.js'], DEST = 'js', processJs = function(){ util.log('Processing: ['+ SRC.join(' | ') +']'); var stream = gulp.src(SRC) .pipe(uglify()) .pipe(concat('scripts.min.js')) .pipe(gulp.dest(DEST)); return stream; }; gulp.task('default', function(){ var delay = 2000, timer, watcher = gulp.watch( SRC, // Callback triggered whatever the event type is (added / changed / deleted) function(event) { // .path | .type // If the timer was assigned a timeout id few time ago.. // Prevent last postpone task to be run if(timer){ clearTimeout(timer); } // Postpone the task timer = setTimeout( function(){processJs();timer=0;} ,delay ); } ); util.log("/!\\ Watching job "+ Array(25).join('~')); });
Stphane
source share