Skip to content

Commit

Permalink
fix: Revert back to drive path capitalization on windows (#161)
Browse files Browse the repository at this point in the history
Applied it to both test file pattern and cwd
  • Loading branch information
saitonakamura committed Jul 1, 2023
1 parent eb6abdc commit 1afa62e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/pure/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,17 @@ export function isNodeAvailable(
})
}

const removeDriveLetter = (string: string) => {
if (string.match(/^[a-zA-Z]:/))
return string.slice(2)
const capitalizeDriveLetter = (path: string) => {
if (path.match(/^[a-zA-Z]:/))
return path.charAt(0).toUpperCase() + path.slice(1)

return string
return path
}
const replaceDoubleSlashes = (string: string) => string.replace(/\\/g, '/')

export function sanitizeFilePath(path: string, isTestPattern: boolean) {
export function sanitizeFilePath(path: string) {
if (isWindows) {
if (isTestPattern)
return replaceDoubleSlashes(removeDriveLetter(path))
else
return replaceDoubleSlashes(path)
return replaceDoubleSlashes(capitalizeDriveLetter(path))
}

return path
Expand Down

0 comments on commit 1afa62e

Please sign in to comment.