Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: report: ability to use dynamic source maps for ?count=x imported files #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feature: report: ability to use dynamic source maps for ?count=x im…
…ported files (#325)
  • Loading branch information
coderaiser committed Jun 10, 2024
commit 157da19bcaf8055dd41cfe619e17482cba7e7422
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://github.com/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
Loading