From b4299e477dbb9401ef29869815d6498a0e92e7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Thu, 30 Nov 2023 16:18:22 +0900 Subject: [PATCH] fix: trim repository prefix correctly (#7) --- src/stacktrace/stringify.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/stacktrace/stringify.ts b/src/stacktrace/stringify.ts index 6190c82..332e292 100644 --- a/src/stacktrace/stringify.ts +++ b/src/stacktrace/stringify.ts @@ -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[], @@ -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) }