Skip to content

Commit 60128ce

Browse files
committed
fix: Fixed path normalization in Windows.
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 69a6d3a commit 60128ce

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ export type GenericObject = Record<string, any>
44

55
export type NodeError = NodeJS.ErrnoException
66

7-
let processRoot = process.cwd()
7+
const processRoot = process.cwd()
8+
let fileProcessRoot = `file://${processRoot}`
89

910
/* c8 ignore next 3 - Windows specific */
1011
if (process.platform === 'win32') {
11-
processRoot = '/' + process.cwd().replaceAll(sep, '/')
12+
fileProcessRoot = 'file:///' + process.cwd().replaceAll(sep, '/')
1213
}
1314

1415
export function pascalCase(original: string): string {
@@ -50,7 +51,15 @@ export function serializeError(error: Error, omitStack: boolean = false): Generi
5051
serialized.stack = (error.stack ?? '')
5152
.split('\n')
5253
.slice(1)
53-
.map(s => s.trim().replace(/^at /, '').replace(processRoot, '$ROOT'))
54+
.map(s =>
55+
s
56+
.trim()
57+
.replace(/^at /, '')
58+
.replace(/^at /, '')
59+
.replace(fileProcessRoot, 'file://$ROOT')
60+
.replace(processRoot, '$ROOT')
61+
.replaceAll(sep, '/')
62+
)
5463
}
5564

5665
addAdditionalProperties(serialized, error)

0 commit comments

Comments
 (0)