Skip to content

Commit

Permalink
Preserve pnpm lockfile version when pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 committed Aug 4, 2024
1 parent b9f544e commit 2f2f5ba
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function generatePnpmLockfile({
* versions after 9, because we might get lucky. If it does change, things
* would break either way.
*/
const useVersion9 = majorVersion >= 9;
const useReadVersion9 = majorVersion >= 9;

const { includeDevDependencies, includePatchedDependencies } = useConfig();
const log = useLogger();
Expand All @@ -51,7 +51,7 @@ export async function generatePnpmLockfile({
try {
const isRush = isRushWorkspace(workspaceRootDir);

const lockfile = useVersion9
const lockfile = useReadVersion9
? await readWantedLockfile_v9(
isRush
? path.join(workspaceRootDir, "common/config/rush")
Expand All @@ -71,7 +71,11 @@ export async function generatePnpmLockfile({

assert(lockfile, `No input lockfile found at ${workspaceRootDir}`);

const targetImporterId = useVersion9
const [lockfileMajorVersion] = String(lockfile.lockfileVersion).split(".");

const useLockfileVersion9 = lockfileMajorVersion >= "9";

const targetImporterId = useLockfileVersion9
? getLockfileImporterId_v9(workspaceRootDir, targetPackageDir)
: getLockfileImporterId_v8(workspaceRootDir, targetPackageDir);

Expand Down Expand Up @@ -141,7 +145,7 @@ export async function generatePnpmLockfile({

log.debug("Pruning the lockfile");

const prunedLockfile = useVersion9
const prunedLockfile = useLockfileVersion9
? await pruneLockfile_v9(lockfile, targetPackageManifest, ".")
: await pruneLockfile_v8(lockfile, targetPackageManifest, ".");

Expand All @@ -160,7 +164,7 @@ export async function generatePnpmLockfile({
? lockfile.patchedDependencies
: undefined;

useVersion9
useLockfileVersion9
? await writeWantedLockfile_v9(isolateDir, {
...prunedLockfile,
patchedDependencies,
Expand Down

0 comments on commit 2f2f5ba

Please sign in to comment.