dylanb / gulp-coverage

Gulp coverage reporting for Node.js that is independent of the test runner
MIT License
60 stars 12 forks source link

output summary as text #29

Closed mbrevda closed 9 years ago

mbrevda commented 9 years ago

How can I output a summary of coverage as text? Preferably, I'd like to pass the json output to a function so that I can pick the parts I want and console.log them. I tried playing with format/report but I was not able to. Am I missing something?

dylanb commented 9 years ago

The idea is to use the gather task and then to write a Gulp task to take the output of that and process it.

You could add code like this to your gulpfile to achieve what you want to achieve:

var through2 = require('through2');

...

var processor = through2.obj(function (stats, enc, cb) {
    console.log(stats);
    cb();
},
function (cb) {
    cb();
});

...
    return gulp.src(['filesglob'], { read: false })
        .pipe(cover.instrument(options))
        .pipe(tester)
        .pipe(cover.gather())
        .pipe(processor);
...
mbrevda commented 9 years ago

I was not able to figure that from the documentation.

Brilliant, thanks! :+1: