Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Windows Git Bash w/ pnpm #116

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,18 @@ 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);

Expand Down
4 changes: 3 additions & 1 deletion src/lib/lockfile/helpers/pnpm-map-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ function pnpmMapDependenciesLinks(
return value;
}

// 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}`
Expand Down
Loading