Suppose we have gulp-mocha and want add watching to run tests on changes:
gulp.watch(['test/**', 'lib/**'], function () {
gulp.src(['test/*.js'])
.pipe(mocha({ reporter: 'list' }));
});
This fill work fine, until you change multiple files with some git command - watch will call mocha as many times, as many files was changed. And this is perfectly fine, because this is how gulp should work.
But this is definitely a problem - most of the grunt related blog posts are about - "How to rebuild your css/jade/etc on edit". So I see a way in writing gulp plugin throttle (or something, I can't figure proper name) that will buffer incoming events (for 5 seconds then flush) and call callback only once:
gulp.watch(['test/**', 'lib/**']).pipe(throttle(function (events) {
gulp.src(['test/*.js'])
.pipe(mocha({ reporter: 'list' }));
}));
(This will need this #13 to be done)
Any suggestions on that? May be I don't see obvious solution, or missed something in docs.
P.s. gutil.buffer is close, but waits for end of the stream. So maybe gutil.throttle?
Suppose we have gulp-mocha and want add watching to run tests on changes:
This fill work fine, until you change multiple files with some
gitcommand - watch will call mocha as many times, as many files was changed. And this is perfectly fine, because this is how gulp should work.But this is definitely a problem - most of the grunt related blog posts are about - "How to rebuild your css/jade/etc on edit". So I see a way in writing gulp plugin
throttle(or something, I can't figure proper name) that will buffer incoming events (for 5 seconds then flush) and call callback only once:(This will need this #13 to be done)
Any suggestions on that? May be I don't see obvious solution, or missed something in docs.
P.s.
gutil.bufferis close, but waits for end of the stream. So maybegutil.throttle?