我的 gulpfile 中有以下(简化的)设置:
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var watch = require('gulp-watch');
var paths = {
scripts: ['js/*.js']
}
var jscsRunner = jscs({
disallowMixedSpacesAndTabs: true // etc
});
var jshintRunner = jshint({
browser: true // etc
});
// this outputs messages from jshint no problem
gulp.task('jshint', function() {
return gulp.src(paths.scripts)
.pipe(jshintRunner)
.pipe(jshint.reporter('default'));
});
// this outputs messages from jscs no problem
gulp.task('jscs', function() {
return gulp.src(paths.scripts)
.pipe(jscsRunner);
});
// this only outputs messages from jshint
gulp.task('watch', function() {
return watch(paths.scripts)
.pipe(jscsRunner)
.pipe(jshintRunner)
.pipe(jshint.reporter('default'));
});
我的问题是 - 如前所述 - 在watch
任务中没有生成输出jscs
,即使管道与任务中的管道基本完全相同jscs
,它按预期工作。
(我在 Windows 上运行它。)
编辑:此问题已在此处复制和讨论:https ://github.com/jscs-dev/gulp-jscs/pull/66