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: attempt to install specified pnpm version #243

Conversation

puzzler7
Copy link
Contributor

Currently, we only install the latest pnpm version, which fails if the user has specified a pnpm version under packageManager in their package.json. This PR changes that to attempt to parse the version out of the package.json before defaulting to latest.

The pnpm/action-setup action does have logic for parsing the version out of the package.json, but we cannot provide both an version and a version in the package.json, or it will fail (source link).

Tested manually, both with and without the packageManager field.

shell: bash
run: |
if [ -e package.json ] && command -v jq >/dev/null; then
PNPM_VERSION=$(jq -r '.packageManager|split("@")[1]' package.json || echo "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting because the format in package.json is pnpm@version-num and we just need the version number.

Copy link
Contributor

@TylerJang27 TylerJang27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would be nice to at a trunk tools install jq dependency at some point for this

@puzzler7 puzzler7 merged commit f6c5f1b into main May 16, 2024
38 of 40 checks passed
@puzzler7 puzzler7 deleted the maverick/trunk-11473-install-correct-pnpm-version-in-trunk-action branch May 16, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants