Skip to content

Commit

Permalink
fix: upgrade convert-source-map (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 4, 2023
1 parent b0ccf30 commit d2cc490
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
7 changes: 6 additions & 1 deletion lib/v8-to-istanbul.js
Expand Up @@ -9,6 +9,7 @@ const CovFunction = require('./function')
const CovSource = require('./source')
const { sliceRange } = require('./range')
const compatError = Error(`requires Node.js ${require('../package.json').engines.node}`)
const { readFileSync } = require('fs')
let readFile = () => { throw compatError }
try {
readFile = require('fs').promises.readFile
Expand Down Expand Up @@ -49,7 +50,7 @@ module.exports = class V8ToIstanbul {
// if we find a source-map (either inline, or a .map file) we load
// both the transpiled and original source, both of which are used during
// the backflips we perform to remap absolute to relative positions.
convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, dirname(this.path))
convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, this._readFileFromDir.bind(this))

if (this.rawSourceMap) {
if (this.rawSourceMap.sourcemap.sources.length > 1) {
Expand Down Expand Up @@ -89,6 +90,10 @@ module.exports = class V8ToIstanbul {
}
}

_readFileFromDir (filename) {
return readFileSync(resolve(dirname(this.path), filename), 'utf-8')
}

async sourcesContentFromSources () {
const fileList = this.sourceMap.sources.map(relativePath => {
const realPath = this._resolveSource(this.rawSourceMap, relativePath)
Expand Down
64 changes: 39 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.12",
"@types/istanbul-lib-coverage": "^2.0.1",
"convert-source-map": "^1.6.0"
"convert-source-map": "^2.0.0"
},
"devDependencies": {
"@types/node": "^18.0.0",
Expand Down

0 comments on commit d2cc490

Please sign in to comment.