@@ -96,15 +96,33 @@ index d8ebc215f6ad83d472abafe976935acfe5c61b04..021fd2aed1f73ebb4adc449ce6e96f2d
9696
9797 // this implementation is pulled over from istanbul-lib-sourcemap:
9898diff --git a/lib/v8-to-istanbul.js b/lib/v8-to-istanbul.js
99- index 3616437b00658861dc5a8910c64d1449e9fdf467..c1e0c0ae19984480e408713d1691fa174a7c4c1f 100644
99+ index 3616437b00658861dc5a8910c64d1449e9fdf467..4642ca4818ce982e2f186abe4289793768e7cdf9 100644
100100--- a/lib/v8-to-istanbul.js
101101+++ b/lib/v8-to-istanbul.js
102102@@ -1,3 +1,4 @@
103103+ // Patch applied: https://github.com/istanbuljs/v8-to-istanbul/pull/244
104104 const assert = require('assert')
105105 const convertSourceMap = require('convert-source-map')
106106 const util = require('util')
107- @@ -25,12 +26,13 @@ const isNode8 = /^v8\./.test(process.version)
107+ @@ -8,14 +9,9 @@ const CovBranch = require('./branch')
108+ const CovFunction = require('./function')
109+ const CovSource = require('./source')
110+ const { sliceRange } = require('./range')
111+ - const compatError = Error(`requires Node.js ${require('../package.json').engines.node}`)
112+ - const { readFileSync } = require('fs')
113+ - let readFile = () => { throw compatError }
114+ - try {
115+ - readFile = require('fs').promises.readFile
116+ - } catch (_err) {
117+ - // most likely we're on an older version of Node.js.
118+ - }
119+ + const { readFileSync, promises } = require('fs')
120+ + const readFile = promises.readFile
121+ +
122+ const { TraceMap } = require('@jridgewell/trace-mapping')
123+ const isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version)
124+ const isNode8 = /^v8\./.test(process.version)
125+ @@ -25,12 +21,13 @@ const isNode8 = /^v8\./.test(process.version)
108126 const cjsWrapperLength = isOlderNode10 ? require('module').wrapper[0].length : 0
109127
110128 module.exports = class V8ToIstanbul {
@@ -119,7 +137,7 @@ index 3616437b00658861dc5a8910c64d1449e9fdf467..c1e0c0ae19984480e408713d1691fa17
119137 this.sources = sources || {}
120138 this.generatedLines = []
121139 this.branches = {}
122- @@ -58,8 +60 ,8 @@ module.exports = class V8ToIstanbul {
140+ @@ -58,8 +55 ,8 @@ module.exports = class V8ToIstanbul {
123141 if (!this.sourceMap.sourcesContent) {
124142 this.sourceMap.sourcesContent = await this.sourcesContentFromSources()
125143 }
@@ -130,7 +148,7 @@ index 3616437b00658861dc5a8910c64d1449e9fdf467..c1e0c0ae19984480e408713d1691fa17
130148 } else {
131149 const candidatePath = this.rawSourceMap.sourcemap.sources.length >= 1 ? this.rawSourceMap.sourcemap.sources[0] : this.rawSourceMap.sourcemap.file
132150 this.path = this._resolveSource(this.rawSourceMap, candidatePath || this.path)
133- @@ -82,8 +84 ,8 @@ module.exports = class V8ToIstanbul {
151+ @@ -82,8 +79 ,8 @@ module.exports = class V8ToIstanbul {
134152 // We fallback to reading the original source from disk.
135153 originalRawSource = await readFile(this.path, 'utf8')
136154 }
@@ -141,7 +159,7 @@ index 3616437b00658861dc5a8910c64d1449e9fdf467..c1e0c0ae19984480e408713d1691fa17
141159 }
142160 } else {
143161 this.covSources = [{ source: new CovSource(rawSource, this.wrapperLength), path: this.path }]
144- @@ -281,8 +283 ,10 @@ module.exports = class V8ToIstanbul {
162+ @@ -281,8 +278 ,10 @@ module.exports = class V8ToIstanbul {
145163 s: {}
146164 }
147165 source.lines.forEach((line, index) => {
0 commit comments