Skip to content

Commit

Permalink
fix(pnpm): use latest pnpm when upgrading pnpm (#22309)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed May 19, 2023
1 parent cb909fe commit 8d372fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/modules/manager/npm/post-update/pnpm.spec.ts
Expand Up @@ -98,6 +98,7 @@ describe('modules/manager/npm/post-update/pnpm', () => {
depType: 'packageManager',
depName: 'pnpm',
newValue: '6.16.1',
newVersion: '6.16.1',
},
]);
expect(fs.readLocalFile).toHaveBeenCalledTimes(1);
Expand Down
13 changes: 12 additions & 1 deletion lib/modules/manager/npm/post-update/pnpm.ts
Expand Up @@ -16,6 +16,15 @@ import type { NpmPackage } from '../extract/types';
import { getNodeToolConstraint } from './node-version';
import type { GenerateLockFileResult, PnpmLockFile } from './types';

function getPnpmConstraintFromUpgrades(upgrades: Upgrade[]): string | null {
for (const upgrade of upgrades) {
if (upgrade.depName === 'pnpm' && upgrade.newVersion) {
return upgrade.newVersion;
}
}
return null;
}

export async function generateLockFile(
lockFileDir: string,
env: NodeJS.ProcessEnv,
Expand All @@ -32,7 +41,9 @@ export async function generateLockFile(
const pnpmToolConstraint: ToolConstraint = {
toolName: 'pnpm',
constraint:
config.constraints?.pnpm ?? (await getPnpmConstraint(lockFileDir)),
getPnpmConstraintFromUpgrades(upgrades) ??
config.constraints?.pnpm ??
(await getPnpmConstraint(lockFileDir)),
};

const extraEnv: ExtraEnv = {
Expand Down

0 comments on commit 8d372fc

Please sign in to comment.