mirror of
https://github.com/pnpm/action-setup.git
synced 2026-05-14 22:33:32 +08:00
fix: honor devEngines.packageManager.onFail=error (#252)
Export pnpm_config_pm_on_fail=download so the bootstrap pnpm switches to the version pinned in devEngines.packageManager instead of throwing BAD_PM_VERSION on the user's first invocation.
This commit is contained in:
51
.github/workflows/test.yaml
vendored
51
.github/workflows/test.yaml
vendored
@@ -298,6 +298,57 @@ jobs:
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
test_dev_engines_on_fail_error:
|
||||
name: 'Test devEngines.packageManager with onFail=error (${{ matrix.version }}, ${{ matrix.os }})'
|
||||
# Regression test for #252: with devEngines.packageManager.onFail="error" and no
|
||||
# `version:` input, the user's first `pnpm` call hit BAD_PM_VERSION because the
|
||||
# bootstrap version didn't match. The action now exports
|
||||
# pnpm_config_pm_on_fail=download so pnpm switches versions instead of erroring.
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
version:
|
||||
- '9.15.5'
|
||||
- '>=9.15.0'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
|
||||
- name: Set up package.json with devEngines.packageManager onFail=error
|
||||
run: echo '{"devEngines":{"packageManager":{"name":"pnpm","version":"${{ matrix.version }}","onFail":"error"}}}' > package.json
|
||||
shell: bash
|
||||
|
||||
- name: Run the action
|
||||
uses: ./
|
||||
|
||||
- name: 'Test: version'
|
||||
run: |
|
||||
set -e
|
||||
required='${{ matrix.version }}'
|
||||
actual="$(pnpm --version)"
|
||||
echo "pnpm version: ${actual}"
|
||||
|
||||
if [ "${required}" = ">=9.15.0" ]; then
|
||||
min="9.15.0"
|
||||
if [ "$(printf '%s\n' "${min}" "${actual}" | sort -V | head -n1)" != "${min}" ]; then
|
||||
echo "Expected pnpm version >= ${min}, but got ${actual}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "${actual}" != "${required}" ]; then
|
||||
echo "Expected pnpm version ${required}, but got ${actual}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
test_run_install:
|
||||
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user