Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Add relative option to lcov format files. #771

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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