File tree Expand file tree Collapse file tree
registry/src/lib/packages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import os from 'node:os'
88import path from 'node:path'
99
1010import WIN32 from '../constants/WIN32'
11- import { isPath } from '../path'
11+ import { isAbsolute , isPath , trimLeadingDotSlash } from '../path'
1212import { readPackageJson } from './operations'
1313
1414import 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 } ` )
You can’t perform that action at this time.
0 commit comments