这是我的配置:
var gulp = require('gulp'),
// load plugins
$ = require('gulp-load-plugins')();
gulp.task('scripts', function () {
return gulp.src([
'app/scripts/**/*.js',
'gulpfile.js',
'protractor.conf.js',
'test/**/*.js'
])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-junit-reporter'))
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.size());
});
jshint-junit-reporter 必须输出到一个文件,我已经试过了:
.pipe($.jshint.reporter('jshint-junit-reporter').pipe(gulp.dest('output.xml')))
和
.pipe($.jshint.reporter('jshint-junit-reporter')).pipe(gulp.dest('output.xml'))
但它只是将 gulp.src 重定向到一个名为 output.xml 的目录
最佳答案
我找到了解决此限制的方法。
确保 npm install --save jshint jshint-junit-reporter gulp-shell
您还需要确保在运行 gulp 的地方有一个 .jshintrc
文件。
然后在你的 gulpfile.js
var shell = require('gulp-shell')
gulp.task('lint-tofile', shell.task(
["node_modules/.bin/jshint www/js/ --reporter=node_modules/jshint-junit-reporter/reporter.js > test/results/lint.xml"],
{ cwd: __dirname, ignoreErrors: true }
));
您需要更改“www/js”和“test/results/lint.xml”位。
我还制作了一个 pull request to the jshint-junit-reporter具有新的 outputFile 选项的维护者。
关于javascript - gulp 记者归档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23289998/