Skip to content

Commit 2952fec

Browse files
committed
fix(path): handle UNC paths correctly on Windows
Allow UNC paths (//server/share) and long paths (\\?\...) while rejecting Unix absolute paths (/usr/...) on Windows. This fixes 4 failing tests in path-resolve.test.mts on Windows CI.
1 parent 10eb00b commit 2952fec

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/cli/src/utils/fs/path-resolve.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ export function findBinPathDetailsSync(binName: string): {
5050
}
5151

5252
export function findNpmDirPathSync(npmBinPath: string): string | undefined {
53-
// On Windows, Unix-style paths (starting with /) are not valid.
54-
if (WIN32 && npmBinPath.startsWith('/')) {
53+
// On Windows, reject Unix absolute paths (starting with / but not //).
54+
// This allows UNC paths: //server/share, \\server\share.
55+
// And long paths: \\?\C:\..., //?/C:/...
56+
// Backslash paths (\\...) don't match startsWith('/') so they pass through.
57+
if (WIN32 && npmBinPath.startsWith('/') && !npmBinPath.startsWith('//')) {
5558
return undefined
5659
}
5760
const MAX_ITERATIONS = 100

0 commit comments

Comments
 (0)