diff --git a/packages/istanbul-reports/lib/lcov/index.js b/packages/istanbul-reports/lib/lcov/index.js index b765b70c..383c2027 100644 --- a/packages/istanbul-reports/lib/lcov/index.js +++ b/packages/istanbul-reports/lib/lcov/index.js @@ -8,10 +8,9 @@ const LcovOnlyReport = require('../lcovonly'); const HtmlReport = require('../html'); class LcovReport extends ReportBase { - constructor() { + constructor(opts) { super(); - - this.lcov = new LcovOnlyReport({ file: 'lcov.info' }); + this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts }); this.html = new HtmlReport({ subdir: 'lcov-report' }); } } diff --git a/packages/istanbul-reports/lib/lcovonly/index.js b/packages/istanbul-reports/lib/lcovonly/index.js index 2cee4fb0..7aa2a866 100644 --- a/packages/istanbul-reports/lib/lcovonly/index.js +++ b/packages/istanbul-reports/lib/lcovonly/index.js @@ -9,6 +9,7 @@ class LcovOnlyReport extends ReportBase { constructor(opts) { super(); this.file = opts.file || 'lcov.info'; + this.projectRoot = opts.projectRoot || process.cwd(); this.contentWriter = null; } @@ -25,9 +26,10 @@ class LcovOnlyReport extends ReportBase { const branches = fc.b; const branchMap = fc.branchMap; const summary = node.getCoverageSummary(); + const path = require('path'); - writer.println('TN:'); //no test name - writer.println('SF:' + fc.path); + writer.println('TN:'); //no test nam + writer.println('SF:' + path.relative(this.projectRoot, fc.path)); Object.values(functionMap).forEach(meta => { writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));