gulp-jscs save report to file

118 Views Asked by At

Is there a possibility to run jscs check and using gulp and save report it produces to a file?
I want junit style xml files reports saved somewhere. I can do this using direct command line call with > but how to do it using proper gulp?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use gulp-log-capture to capture the output of gulp-jscs and write it to a file.

var logCapture = require('gulp-log-capture');

gulp.task('checkstyle', () => {
  return gulp.src('*.js')
    .pipe(jscs({fix:true}))
    .pipe(logCapture.start(console, 'log'))
    .pipe(jscs.reporter('junit'))
    .pipe(logCapture.stop('xml'))
    .pipe(gulp.dest('junit-reports'));
});

Note that this will produce one JUnit-style XML output file per JS input file.