javascript - gulp 记者归档

标签 javascript node.js gulp

这是我的配置:

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/

相关文章:

javascript - 使用递归搜索对对象中的数组进行排序

angularjs - Paypal 与单页应用程序的集成

node.js - NoDecodeDelegateForThisImageFormat `TIFF\"' aws lambda

node.js - 将 API 数据与 MongoDB 数据结合起来

javascript - Gulp Watch 不工作

javascript - AngularJS 中的后台服务

Javascript:日期结果格式错误

javascript - 将代理中间件与 gulp connect 一起使用

javascript - 如何将事件发送到 gulp-tap 的父流中

javascript - extjs 4.2 组合框仅显示商店的唯一条目