How can I pass gulp.watch() to a pipe?
gulp, javascript, node.js
Solution
According to @OverZealous I've found this approach to work using `gulp-watch`:
gulp.task('default', function() {
gulp.src(base + 'javascripts/**/*.js', { read: false })
.pipe(watch())
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
The `{ read: false }` is required to avoid linting all files on startup. This solution does not lint files that didn't exist when first being started.
Problem
I have a simple default tasking for linting changed js files: ``` gulp.task('default', function() { // watch for JS changes gulp.watch(base + 'javascripts/**/*.js', function() { gulp.run('jshint'); }); }); ``` The problem is that the `jshint` task again sources the files: ``` gulp.task('jshint', function() { gulp.src([base + 'javascripts/*.js']) .pipe(jshint()) .pipe(jshint.reporter('default')); }); ``` What happens is that all files are linted, not only the changed ones. Is there a way to pass only the changed files to jshint?