Skip to content

Commit

Permalink
feat: Add support for projectRoot option (#492)
Browse files Browse the repository at this point in the history
Co-authored-by: Baptiste Gallet <bgallet@iris-info.com>
  • Loading branch information
2 people authored and coreyfarrell committed Nov 21, 2019
1 parent c69ce0c commit 177fd45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/istanbul-reports/lib/lcov/index.js
Expand Up @@ -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' });
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/istanbul-reports/lib/lcovonly/index.js
Expand Up @@ -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;
}

Expand All @@ -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(','));
Expand Down

0 comments on commit 177fd45

Please sign in to comment.