Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional configuration 'projectRoot' #532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/istanbul-reports/lib/lcovonly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
const { ReportBase } = require('istanbul-lib-report');
const {ReportBase} = require('istanbul-lib-report');

class LcovOnlyReport extends ReportBase {
constructor(opts) {
super();
this.file = opts.file || 'lcov.info';
this.projectRoot = opts.projectRoot || process.cwd();
this.projectRoot = opts.projectRoot || null;
this.contentWriter = null;
}

Expand All @@ -29,7 +29,7 @@ class LcovOnlyReport extends ReportBase {
const path = require('path');

writer.println('TN:'); //no test nam
writer.println('SF:' + path.relative(this.projectRoot, fc.path));
writer.println('SF:' + (this.projectRoot ? path.relative(this.projectRoot, fc.path) : fc.path));

Object.values(functionMap).forEach(meta => {
writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));
Expand All @@ -50,7 +50,7 @@ class LcovOnlyReport extends ReportBase {

Object.entries(branches).forEach(([key, branchArray]) => {
const meta = branchMap[key];
const { line } = meta.loc.start;
const {line} = meta.loc.start;
branchArray.forEach((b, i) => {
writer.println('BRDA:' + [line, key, i, b].join(','));
});
Expand Down