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 (#325)
  • Loading branch information
coderaiser committed Jun 10, 2024
1 parent dc38051 commit 157da19
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 @@ -109,7 +109,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._shouldInstrument(path)
Expand Down Expand Up @@ -146,7 +146,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:/nodejs/node/pull/34305
if (!sourceMapAndLineLengths.data) return
Expand Down Expand Up @@ -346,15 +346,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._shouldInstrument(v8ScriptCov.url)) {

if ((!this.omitRelative || /^file:\/\//.test(v8ScriptCov.url))) {
if (this.excludeAfterRemap || this.exclude.shouldInstrument(fileURLToPath(v8ScriptCov.url))) {
result.push(v8ScriptCov)
}
}
Expand All @@ -374,7 +374,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 157da19

Please sign in to comment.