[Fix] `nvm install-latest-npm`: ensure npm 8 does not install on unsupported nodes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jordan Harband · committed by Jordan Harband · parent 2bda9fd · Browse files · 3 files·+44 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+44 added−0 removed
- tests:+7 added−0 removed
- other:+37 added−0 removed
Provenance
- Commit
ebbd30e- Tree
5a1f8f5- Author
Jordan Harband <ljharb@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
2bda9fd
3 files changed+44 added−0 removed
modified:.github/workflows/latest-npm.yml+5 added
11 unmodified lines1213141516171819202122232436 unmodified lines11 unmodified lines strategy: fail-fast: false matrix: node-version: - "16" - "15" - "14" - "13" - "12" - "11" - "10" - "9" - "9.2"36 unmodified linesmodified:test/installation_node/install latest npm+7 added
7 unmodified lines8 \. ../../nvm.sh9 set -e10 11 nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 1'12+nvm install 12.12 >/dev/null 2>&1 || die 'install v12.12 failed'13+nvm install-latest-npm || die 'nvm install-latest-npm failed: 1'14+NPM_VERSION="$(npm --version)"15+nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 7.0.0 \16+&& nvm_version_greater 8.0.0 "${NPM_VERSION}" || die "node v12.12 updates to ${NPM_VERSION}; expected v7"17+18+nvm deactivate >/dev/null 2>&1 || die 'unable to deactivate: 1'19 nvm install 4 >/dev/null 2>&1 || die 'install v4 failed'20 nvm install-latest-npm || die 'nvm install-latest-npm failed: 1'21 NPM_VERSION="$(npm --version)"22 nvm_version_greater_than_or_equal_to "${NPM_VERSION}" 5.0.0 || die "node v4.x updates to ${NPM_VERSION}; expected >= v5"29 unmodified linesmodified:nvm.sh+32 added
266 unmodified lines267 NVM_IS_10_OR_ABOVE=0268 if [ $NVM_IS_9_3_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 10.0.0; then269 NVM_IS_10_OR_ABOVE=1270 fi271+ local NVM_IS_12_LTS_OR_ABOVE272+ NVM_IS_12_LTS_OR_ABOVE=0273+ if [ $NVM_IS_10_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 12.13.0; then274+ NVM_IS_12_LTS_OR_ABOVE=1275+ fi276+ local NVM_IS_13_OR_ABOVE277+ NVM_IS_13_OR_ABOVE=0278+ if [ $NVM_IS_12_LTS_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 13.0.0; then279+ NVM_IS_13_OR_ABOVE=1280+ fi281+ local NVM_IS_14_LTS_OR_ABOVE282+ NVM_IS_14_LTS_OR_ABOVE=0283+ if [ $NVM_IS_13_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 14.15.0; then284+ NVM_IS_14_LTS_OR_ABOVE=1285+ fi286+ local NVM_IS_15_OR_ABOVE287+ NVM_IS_15_OR_ABOVE=0288+ if [ $NVM_IS_14_LTS_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 15.0.0; then289+ NVM_IS_15_OR_ABOVE=1290+ fi291+ local NVM_IS_16_OR_ABOVE292+ NVM_IS_16_OR_ABOVE=0293+ if [ $NVM_IS_15_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 16.0.0; then294+ NVM_IS_16_OR_ABOVE=1295+ fi296 297 if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {298 [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \299 }; then13 unmodified lines313 $NVM_NPM_CMD install -g npm@6.9314 elif [ $NVM_IS_10_OR_ABOVE -eq 0 ]; then315 nvm_echo '* `npm` `v6.x` is the last version that works on `node` below `v10.0.0`'316 $NVM_NPM_CMD install -g npm@6317+ elif \318+ [ $NVM_IS_12_LTS_OR_ABOVE -eq 0 ] \319+ || { [ $NVM_IS_13_OR_ABOVE -eq 1 ] && [ $NVM_IS_14_LTS_OR_ABOVE -eq 0 ]; } \320+ || { [ $NVM_IS_15_OR_ABOVE -eq 1 ] && [ $NVM_IS_16_OR_ABOVE -eq 0 ]; } \321+ ; then322+ nvm_echo '* `npm` `v7.x` is the last version that works on `node` `v13`, `v15`, below `v12.13`, or `v14.0` - `v14.15`'323+ $NVM_NPM_CMD install -g npm@7324 else325 nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'326 $NVM_NPM_CMD install -g npm327 fi3962 unmodified lines