index.js 909 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. /*
  3. Copyright 2012-2015, Yahoo Inc.
  4. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  5. */
  6. const { ReportBase } = require('istanbul-lib-report');
  7. const LcovOnlyReport = require('../lcovonly');
  8. const HtmlReport = require('../html');
  9. class LcovReport extends ReportBase {
  10. constructor(opts) {
  11. super();
  12. this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts });
  13. this.html = new HtmlReport({ subdir: 'lcov-report' });
  14. }
  15. }
  16. ['Start', 'End', 'Summary', 'SummaryEnd', 'Detail'].forEach(what => {
  17. const meth = 'on' + what;
  18. LcovReport.prototype[meth] = function(...args) {
  19. const lcov = this.lcov;
  20. const html = this.html;
  21. if (lcov[meth]) {
  22. lcov[meth](...args);
  23. }
  24. if (html[meth]) {
  25. html[meth](...args);
  26. }
  27. };
  28. });
  29. module.exports = LcovReport;