Skip to content

Commit 177fd45

Browse files
bgalletbgalletBaptiste Gallet
authored andcommittedNov 21, 2019
feat: Add support for projectRoot option (#492)
Co-authored-by: Baptiste Gallet <bgallet@iris-info.com>
1 parent c69ce0c commit 177fd45

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎packages/istanbul-reports/lib/lcov/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ const LcovOnlyReport = require('../lcovonly');
88
const HtmlReport = require('../html');
99

1010
class LcovReport extends ReportBase {
11-
constructor() {
11+
constructor(opts) {
1212
super();
13-
14-
this.lcov = new LcovOnlyReport({ file: 'lcov.info' });
13+
this.lcov = new LcovOnlyReport({ file: 'lcov.info', ...opts });
1514
this.html = new HtmlReport({ subdir: 'lcov-report' });
1615
}
1716
}

‎packages/istanbul-reports/lib/lcovonly/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class LcovOnlyReport extends ReportBase {
99
constructor(opts) {
1010
super();
1111
this.file = opts.file || 'lcov.info';
12+
this.projectRoot = opts.projectRoot || process.cwd();
1213
this.contentWriter = null;
1314
}
1415

@@ -25,9 +26,10 @@ class LcovOnlyReport extends ReportBase {
2526
const branches = fc.b;
2627
const branchMap = fc.branchMap;
2728
const summary = node.getCoverageSummary();
29+
const path = require('path');
2830

29-
writer.println('TN:'); //no test name
30-
writer.println('SF:' + fc.path);
31+
writer.println('TN:'); //no test nam
32+
writer.println('SF:' + path.relative(this.projectRoot, fc.path));
3133

3234
Object.values(functionMap).forEach(meta => {
3335
writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));

0 commit comments

Comments
 (0)
Please sign in to comment.