-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CI workflow and add merge-lcov script
- Loading branch information
1 parent
c7961d9
commit 75d0bda
Showing
3 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const glob = require('glob'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const getLcovFiles = function (src) { | ||
return new Promise((resolve, reject) => { | ||
glob(`${src}/**/lcov.info`, (error, result) => { | ||
if (error) return reject(error); | ||
resolve(result); | ||
return null; | ||
}); | ||
}); | ||
}; | ||
|
||
(async function () { | ||
const files = await getLcovFiles('coverage'); | ||
if (files && files instanceof Array) { | ||
const mergedReport = files.reduce( | ||
(report, currFile) => (report += fs.readFileSync(currFile)), | ||
'', | ||
); | ||
await fs.writeFile( | ||
path.resolve('./coverage/lcov.info'), | ||
mergedReport, | ||
(err) => { | ||
if (err) console.log(err); // skipcq: JS-0002 | ||
console.log('The file has been saved!'); // skipcq: JS-0002 | ||
return null; | ||
}, | ||
); | ||
} | ||
})(); |