Skip to content

Commit

Permalink
fix: trim repository prefix correctly (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Nov 30, 2023
1 parent e067dbb commit b4299e4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/stacktrace/stringify.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type { ParsedStack } from 'vitest'

const repository = process.env.GITHUB_REPOSITORY?.split('/')[1] ?? ''
const repositoryPrefixes = [
`D:/a/${repository}/`,
`/home/runner/work/${repository}/`
]
const repository = process.env.GITHUB_WORKSPACE
const repositoryPrefixes = repository ? [repository.replace(/\/?$/, '/')] : []

export const stringifyStacktrace = (
stack: ParsedStack[],
Expand All @@ -13,7 +10,7 @@ export const stringifyStacktrace = (
return stack
.map(s => {
let file = s.file
if (trimRepositoryPrefix) {
if (trimRepositoryPrefix && repositoryPrefixes.length > 0) {
file = trimPrefixes(file, repositoryPrefixes)
}

Expand Down

0 comments on commit b4299e4

Please sign in to comment.