Skip to content

Commit

Permalink
fix(task.js): return sourceRoot+source if source doesn't include file…
Browse files Browse the repository at this point in the history
…Name in fixSourcePaths
  • Loading branch information
maiieul committed Dec 18, 2024
1 parent b3adfa7 commit 7b79901
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/fix-source-paths.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('fixSourcePaths', () => {
'/absolute/src/component.vue': {
path: '/absolute/src/component.vue',
inputSourceMap: {
sources: ['/absolute/src/component.vue', 'otherFile.js'],
sources: ['/absolute/src/component.vue', 'src/otherFile.js'],
sourceRoot: ''
}
},
Expand Down
6 changes: 4 additions & 2 deletions support-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ function fixSourcePaths(coverage) {
const fileName = /([^\/\\]+)$/.exec(absolutePath)[1]
if (!fileName) return

if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = ''
inputSourceMap.sources = inputSourceMap.sources.map((source) =>
source.includes(fileName) ? absolutePath : source
source.includes(fileName)
? absolutePath
: `${inputSourceMap.sourceRoot}/${source}`
)
if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = ''
})
}

Expand Down

0 comments on commit 7b79901

Please sign in to comment.