From 7242ee34bdb65c7b1f04962ab99c7c2ab6058cb2 Mon Sep 17 00:00:00 2001 From: Pablo Miranda Date: Fri, 22 May 2015 20:14:50 -0700 Subject: [PATCH] adds support for individual configuration per reporter --- index.js | 3 ++- test/main.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2b8832a..ec0b73b 100644 --- a/index.js +++ b/index.js @@ -113,7 +113,8 @@ plugin.writeReports = function (opts) { } reporters = reporters.map(function (r) { - return Report.create(r, _.clone(opts.reportOpts)); + var reportOpts = opts.reportOpts[r] || opts.reportOpts; + return Report.create(r, _.clone(reportOpts)); }); var cover = through(); diff --git a/test/main.js b/test/main.js index cd4b22b..484d258 100644 --- a/test/main.js +++ b/test/main.js @@ -248,6 +248,30 @@ describe('gulp-istanbul', function () { }); }); + it('allow specifying configuration per report', function (done) { + process.stdout.write = function () {}; + var opts = { + reporters: ['lcovonly', 'json'], + reportOpts: { + lcovonly: { dir: 'lcovonly', file: 'lcov-test.info' }, + json: { dir: 'json', file: 'json-test.info' } + } + }; + + gulp.src(['test/fixtures/test/*.js']) + .pipe(mocha()) + .pipe(istanbul.writeReports(opts)) + .on('end', function() { + process.stdout.write = out; + assert(fs.existsSync('./lcovonly')); + assert(fs.existsSync('./lcovonly/lcov-test.info')); + assert(fs.existsSync('./json')); + assert(fs.existsSync('./json/json-test.info')); + process.stdout.write = out; + done(); + }); + }); + it('allows specifying custom reporters', function (done) { var ExampleReport = function() {}; ExampleReport.TYPE = 'example';