diff --git a/lib/app.js b/lib/app.js index 68ddd28..6cd6ed5 100644 --- a/lib/app.js +++ b/lib/app.js @@ -218,11 +218,12 @@ class App { return new Promise((resolve, reject) => { try { this.coverage.generate(this.events, `${this.workingDir}/contracts`); + const newCoverage = App.makeKeysRelative(this.coverage.coverage, this.workingDir); - const json = JSON.stringify(this.coverage.coverage); + const json = JSON.stringify(newCoverage); fs.writeFileSync('./coverage.json', json); - collector.add(this.coverage.coverage); + collector.add(newCoverage); reporter.add('html'); reporter.add('lcov'); reporter.add('text'); @@ -240,6 +241,14 @@ class App { // ------------------------------------------ Utils ---------------------------------------------- + static makeKeysRelative(map, root) { + const newCoverage = {}; + Object.keys(map).forEach(pathKey => { + newCoverage[path.relative(root, pathKey)] = map[pathKey]; + }); + return newCoverage; + } + /** * Allows config to turn logging off (for CI) * @param {Boolean} isSilent