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(pnpm): use latest pnpm when upgrading pnpm #22309

Merged
merged 1 commit into from May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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