diff --git a/src/lib/lockfile/helpers/generate-pnpm-lockfile.ts b/src/lib/lockfile/helpers/generate-pnpm-lockfile.ts index f3aa30e..34556a5 100644 --- a/src/lib/lockfile/helpers/generate-pnpm-lockfile.ts +++ b/src/lib/lockfile/helpers/generate-pnpm-lockfile.ts @@ -91,7 +91,17 @@ export async function generatePnpmLockfile({ * importer ids in the context of a lockfile. */ ...Object.values(directoryByPackageName), - ]; + /** + * Split the path by the OS separator and join it back with the POSIX + * separator. + * + * The importerIds are built from directory names, so Windows Git Bash + * environments will have double backslashes in their ids: + * "packages\common" vs. "packages/common". Without this split & join, any + * packages not on the top-level will have ill-formatted importerIds and + * their entries will be missing from the lockfile.importers list. + */ + ].map((x) => x.split(path.sep).join(path.posix.sep)); log.debug("Relevant importer ids:", relevantImporterIds); diff --git a/src/lib/lockfile/helpers/pnpm-map-importer.ts b/src/lib/lockfile/helpers/pnpm-map-importer.ts index 4f33f31..6dd805e 100644 --- a/src/lib/lockfile/helpers/pnpm-map-importer.ts +++ b/src/lib/lockfile/helpers/pnpm-map-importer.ts @@ -49,10 +49,10 @@ function pnpmMapDependenciesLinks( return value; } - const relativePath = path.relative( - importerPath, - directoryByPackageName[key] - ); + // Replace backslashes with forward slashes to support Windows Git Bash + const relativePath = path + .relative(importerPath, directoryByPackageName[key]) + .replace(path.sep, path.posix.sep); return relativePath.startsWith(".") ? `link:${relativePath}`