From 30eedbec7bb1b5b31aa6548e188bbd0cb31bb3fc Mon Sep 17 00:00:00 2001 From: Dan Phifer Date: Wed, 27 Sep 2017 15:32:03 +0800 Subject: [PATCH] Providing relative paths to Istanbul. now reports actually show up in the reports directory rather than next to my .sol files and css/js references work --- lib/app.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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