0

what's wrong with this code:

var gulp = require('gulp');
var watch = require('gulp-watch');
var connect = require('gulp-connect');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');

//lint
module.exports = gulp.task('lint', function () {
  return gulp.src([config.paths.src.scripts,config.paths.exclude.bower])
  .pipe(jshint())
  .pipe(jshint.reporter(stylish));
});

//watch
module.exports = gulp.task('watch', function () {
    watch(config.paths.src.scripts, ['lint'])
        .pipe(connect.reload());
    watch(config.paths.src.templates, ['templates'])
        .pipe(connect.reload());
    watch(config.paths.src.index)
        .pipe(connect.reload());
});

when ie I edit a js file doing an error jshint show me nothing.

This works:

watch(config.paths.src.scripts)
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
        .pipe(connect.reload());

but it's quite the same or not ?

Whisher
  • 31,320
  • 32
  • 120
  • 201
  • Double `module.exports` seems quite suspicious. Are those tasks in separate files? – Heikki Nov 11 '14 at 20:33
  • Related: http://stackoverflow.com/questions/26476226/gulp-watch-not-running-subsequent-task/26480579#26480579 – Heikki Nov 11 '14 at 20:41
  • @Heikki Yes they are I've loaded it like https://gist.github.com/whisher/102a89b75a7ef554bd52 – Whisher Nov 11 '14 at 22:25

1 Answers1

1

gulp-watch does not support an array of task names like the internal gulp.watch. See documentation at https://www.npmjs.org/package/gulp-watch

You have to provide gulp-watch a function, something like

watch(config.paths.src.scripts, function(events, done) {
   gulp.start(['lint'], done);
}

Note: It seems that gulp.start will be deprecated in Gulp 4.x, it will be replaced by a task runner called bach: https://github.com/floatdrop/gulp-watch/issues/92

StrangeLoop
  • 521
  • 1
  • 6
  • 17