Skip to content

Commit

Permalink
feature: report: ability to use dynamic source maps for ?count=x im…
Browse files Browse the repository at this point in the history
…ported files (bcoe#325)
  • Loading branch information
coderaiser authored Jan 2, 2022
1 parent eaf8456 commit deb9b31
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Report {
for (const v8ScriptCov of v8ProcessCov.result) {
try {
const sources = this._getSourceMap(v8ScriptCov)
const path = resolve(this.resolve, v8ScriptCov.url)
const path = resolve(this.resolve, fileURLToPath(v8ScriptCov.url))
const converter = v8toIstanbul(path, this.wrapperLength, sources, (path) => {
if (this.excludeAfterRemap) {
return !this.exclude.shouldInstrument(path)
Expand Down Expand Up @@ -143,7 +143,7 @@ class Report {
*/
_getSourceMap (v8ScriptCov) {
const sources = {}
const sourceMapAndLineLengths = this.sourceMapCache[pathToFileURL(v8ScriptCov.url).href]
const sourceMapAndLineLengths = this.sourceMapCache[v8ScriptCov.url]
if (sourceMapAndLineLengths) {
// See: https://github.com/nodejs/node/pull/34305
if (!sourceMapAndLineLengths.data) return
Expand Down Expand Up @@ -279,15 +279,15 @@ class Report {
}
if (/^file:\/\//.test(v8ScriptCov.url)) {
try {
v8ScriptCov.url = fileURLToPath(v8ScriptCov.url)
fileIndex.add(v8ScriptCov.url)
} catch (err) {
debuglog(`${err.stack}`)
continue
}
}
if ((!this.omitRelative || isAbsolute(v8ScriptCov.url))) {
if (this.excludeAfterRemap || this.exclude.shouldInstrument(v8ScriptCov.url)) {

if ((!this.omitRelative || /^file:\/\//.test(v8ScriptCov.url))) {
if (this.excludeAfterRemap || this.exclude.shouldInstrument(fileURLToPath(v8ScriptCov.url))) {
result.push(v8ScriptCov)
}
}
Expand All @@ -307,7 +307,7 @@ class Report {
_normalizeSourceMapCache (v8SourceMapCache) {
const cache = {}
for (const fileURL of Object.keys(v8SourceMapCache)) {
cache[pathToFileURL(fileURLToPath(fileURL)).href] = v8SourceMapCache[fileURL]
cache[fileURL] = v8SourceMapCache[fileURL];
}
return cache
}
Expand Down

0 comments on commit deb9b31

Please sign in to comment.