Skip to content

Commit

Permalink
Add relative option to lcov format files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Rincon authored and moos committed Jul 8, 2020
1 parent fe96bc7 commit 0a6ff5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/report/lcov.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function LcovReport(opts) {
htmlDir = path.resolve(baseDir, 'lcov-report');

mkdirp.sync(baseDir);
this.lcov = new LcovOnlyReport({ dir: baseDir, watermarks: opts.watermarks });
this.lcov = new LcovOnlyReport({ dir: baseDir, watermarks: opts.watermarks, relative: opts.relative});
this.html = new HtmlReport({ dir: htmlDir, watermarks: opts.watermarks, sourceStore: opts.sourceStore});
}

Expand Down
4 changes: 3 additions & 1 deletion lib/report/lcovonly.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ var path = require('path'),
* @constructor
* @param {Object} opts optional
* @param {String} [opts.dir] the directory in which to the `lcov.info` file. Defaults to `process.cwd()`
* @param {Boolean} [opts.relative] If true paths reported will be relative to `process.cwd()`. Defaults to `false`
*/
function LcovOnlyReport(opts) {
this.opts = opts || {};
this.opts.dir = this.opts.dir || process.cwd();
this.opts.relative = this.opts.relative || false;
this.opts.file = this.opts.file || this.getDefaultConfig().file;
this.opts.writer = this.opts.writer || null;
}
Expand All @@ -49,7 +51,7 @@ Report.mix(LcovOnlyReport, {
summary = utils.summarizeFileCoverage(fc);

writer.println('TN:'); //no test name
writer.println('SF:' + fc.path);
writer.println('SF:' + (this.opts.relative ? path.relative(process.cwd(), fc.path) : fc.path));

Object.keys(functions).forEach(function (key) {
var meta = functionMap[key];
Expand Down

0 comments on commit 0a6ff5b

Please sign in to comment.