Only check packageManager if it actually specifies pnpm

We upgrade to version 4 and started seeing the following weird error:

```
Error: Multiple versions of pnpm specified:
  Error: Error: Multiple versions of pnpm specified:
    - version 9 in the GitHub Action config with the key "version"
    - version yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e in the package.json with the key "packageManager"
  Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION
    - version 9 in the GitHub Action config with the key "version"
    - version yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e in the package.json with the key "packageManager"
```

Even though we don't specify `packageManager` in `package.json` explicitly.

Either way this change seems like an improvement to do `pnpm` version validation only if it's actually `pnpm`.
This commit is contained in:
Fedor Korotkov 2024-08-23 15:54:49 -04:00 committed by GitHub
parent ac5bf11548
commit 9ea357d1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,7 +58,7 @@ async function readTarget(opts: {
if (version) {
if (
typeof packageManager === 'string' &&
typeof packageManager === 'string' && packageManager.contains("pnpm@") &&
packageManager.replace('pnpm@', '') !== version
) {
throw new Error(`Multiple versions of pnpm specified: