以下是gulpfile.js:
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
connect = require('gulp-connect');
gulp.task('jshint', function(){
gulp.src('app/scripts/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('html', function(){
gulp.src('app/index.html')
.pipe(connect.reload());
});
gulp.task('watch', function(){
gulp.watch('app/index.html', ['html']);
gulp.watch('app/scripts/*.js', ['jshint']);
});
gulp.task('serve', function(){
connect.server({
root: 'app',
port: '9001',
livereload: true
});
});
gulp.task('default', ['jshint', 'serve', 'watch']);当我编辑我的app/scripts/*.js时,jshint任务将运行两次。为什么?我的gulpfile.js有什么问题吗?
谢谢。
发布于 2014-07-09 08:30:42
似乎你的默认任务是负责任的。
它执行jshing任务(到目前为止执行了1次),然后服务任务(ok),最后观察,这将再次执行jshint。
如果您已经将jshint传递给您的文件,也许您应该从默认的任务中删除jshint任务,并创建另一个不正在监视的jshint任务,因此您只执行该任务一次,并且您只需要监视新的文件。
https://stackoverflow.com/questions/23927251
复制相似问题