Skip to content

Instantly share code, notes, and snippets.

@philpalmieri
Created December 2, 2020 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philpalmieri/0591a3130ad168428deff4d314b97d5f to your computer and use it in GitHub Desktop.
Save philpalmieri/0591a3130ad168428deff4d314b97d5f to your computer and use it in GitHub Desktop.
///////////////////////////////
package.json
////////////////////////////////
"scripts": {
"fixlcov": "node fixlcov.js"
},
/////////////////////////////////
fixlcov.js
///////////////////////////////
'use strict';
const path = require('path');
const { readFileSync, writeFileSync } = require('fs');
(() => {
const lcovFile = path.resolve(__dirname, './coverage/lcov.info')
const rawFile = readFileSync(lcovFile, 'utf8')
const rebuiltPaths = rawFile.split('\n').map(singleLine => {
if (singleLine.startsWith('SF:')) {
return singleLine.replace('SF:', `SF:${__dirname}/`)
}
return singleLine
}).join('\n')
console.log(rebuiltPaths)
writeFileSync(lcovFile, rebuiltPaths, 'utf8')
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment