| 1 |
'use strict'; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
const { ReportBase } = require('istanbul-lib-report'); |
| 7 |
const LcovOnlyReport = require('../lcovonly'); |
| 8 |
const HtmlReport = require('../html'); |
| 9 |
|
| 10 |
class LcovReport extends ReportBase { |
| 11 |
constructor(opts) { |
| 12 |
super(); |
| 13 |
this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts }); |
| 14 |
this.html = new HtmlReport({ subdir: 'lcov-report' }); |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
['Start', 'End', 'Summary', 'SummaryEnd', 'Detail'].forEach(what => { |
| 19 |
const meth = 'on' + what; |
| 20 |
LcovReport.prototype[meth] = function(...args) { |
| 21 |
const lcov = this.lcov; |
| 22 |
const html = this.html; |
| 23 |
|
| 24 |
if (lcov[meth]) { |
| 25 |
lcov[meth](...args); |
| 26 |
} |
| 27 |
if (html[meth]) { |
| 28 |
html[meth](...args); |
| 29 |
} |
| 30 |
}; |
| 31 |
}); |
| 32 |
|
| 33 |
module.exports = LcovReport; |