Skip to content

Commit 0ebd66b

Browse files
committed
Fix Windows path handling in isolatePackage for cross-drive relative paths
1 parent 8f54997 commit 0ebd66b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

registry/src/lib/packages/isolation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import os from 'node:os'
88
import path from 'node:path'
99

1010
import WIN32 from '../constants/WIN32'
11-
import { isPath } from '../path'
11+
import { isAbsolute, isPath, trimLeadingDotSlash } from '../path'
1212
import { readPackageJson } from './operations'
1313

1414
import type { PackageJson } from '../packages'
@@ -85,7 +85,12 @@ export async function isolatePackage(
8585
// Determine if this is a path or package spec.
8686
if (isPath(packageSpec)) {
8787
// File system path.
88-
sourcePath = path.resolve(packageSpec)
88+
// Handle edge case on Windows where path.relative() returns an absolute path
89+
// when paths are on different drives, and the test prepends './' to it.
90+
// Example: './C:\Users\...' should be treated as 'C:\Users\...'.
91+
const trimmedPath = trimLeadingDotSlash(packageSpec)
92+
const pathToResolve = isAbsolute(trimmedPath) ? trimmedPath : packageSpec
93+
sourcePath = path.resolve(pathToResolve)
8994

9095
if (!existsSync(sourcePath)) {
9196
throw new Error(`Source path does not exist: ${sourcePath}`)

0 commit comments

Comments
 (0)