简体   繁体   English

gulp-watch不更新gulp-jshint

[英]gulp-watch doesn't update gulp-jshint

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. 当我编辑一个js文件时出错jshint给我什么都没有。

This works: 这有效:

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

but it's quite the same or not ? 还是完全一样?

gulp-watch does not support an array of task names like the internal gulp.watch. gulp-watch不支持内部gulp.watch之类的任务名称数组。 See documentation at https://www.npmjs.org/package/gulp-watch 请参阅https://www.npmjs.org/package/gulp-watch上的文档

You have to provide gulp-watch a function, something like 您必须提供gulp-watch功能,例如

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 注意:似乎gulp.start将在Gulp 4.x中被弃用,它将由一个名为bach的任务运行程序代替: https : //github.com/floatdrop/gulp-watch/issues/92

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM