Compare commits

..

17 Commits

Author SHA1 Message Date
ryenus
f28584cecf indent awk script properly 2025-04-14 20:43:17 +08:00
ryenus
fc4a98b771 display a hint when version filtering is in effect
due the use of --min or NVM_MIN, which would show only the versions
higher than the specified min version, and/or the available minor/patch
updates for the installed versions.
2025-04-14 20:43:17 +08:00
ryenus
dd28eb4932 set NVM_NO_COLORS to --no-colors to disable color 2025-04-14 20:43:17 +08:00
ryenus
206a14297c rename min_ver to min for consistency 2025-04-14 20:43:17 +08:00
ryenus
f99c9f30cd [test] avoid leaking temp variable 2025-04-14 20:43:17 +08:00
ryenus
c02964100e ls-remote: introduce temp var for env inheritance
This is to inherit $NVM_MIN from env when defined, meanwhile avoiding
inline local variable initialization for ksh compatibility.

Co-authored-by: Jordan Harband <ljharb@gmail.com>
2025-04-14 20:43:17 +08:00
ryenus
e71918ec8c avoid inline initialization for ksh compatibility
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2025-04-14 20:43:17 +08:00
ryenus
594f8c0a80 ls-remote: add CLI option --min=<version>
When omitted, fallback to the environment variable "NVM_MIN" if set.
And the CLI option --min=<version> takes precedence over the environment
variable "NVM_MIN" if both are present.
2025-04-14 20:43:17 +08:00
ryenus
54a5777ff8 always show updates for installed versions
even if they're older than $NVM_MIN
2025-04-14 20:43:08 +08:00
ryenus
858eda58c4 remove function ref duplication 2025-04-14 20:43:08 +08:00
ryenus
f2b7583b6b prefixed versions like v18 also work 2025-04-14 20:43:08 +08:00
ryenus
b16b4ee6ad rename NVM_MIN_VER to NVM_MIN
since nvm is all about versions, so no need for the explicit suffix.
2025-04-14 20:43:08 +08:00
ryenus
9f4dd6477a trim leading space in mock output due to eclint errors 2025-04-14 20:43:08 +08:00
ryenus
c390144c1e add test for NVM_MIN_VER support
show only versions newer than NVM_MIN_VER if set
2025-04-14 20:43:08 +08:00
ryenus
37811e0d7d always list installed versions 2025-04-14 20:43:08 +08:00
ryenus
48fe276e36 show only versions newer than NVM_MIN_VER if set 2025-04-14 20:43:08 +08:00
Toni Viemerö
99352a64d2
[Fix] nvm_install_latest_npm: fix node version detection 2025-04-09 08:16:05 +03:00

14
nvm.sh
View File

@ -356,19 +356,19 @@ nvm_install_latest_npm() {
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
NVM_IS_20_5_OR_ABOVE=1
fi
local NVM_IS_20_17_or_ABOVE
NVM_IS_20_17_or_ABOVE=0
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then
NVM_IS_20_17_or_ABOVE=1
local NVM_IS_20_17_OR_ABOVE
NVM_IS_20_17_OR_ABOVE=0
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.17.0; then
NVM_IS_20_17_OR_ABOVE=1
fi
local NVM_IS_21_OR_ABOVE
NVM_IS_21_OR_ABOVE=0
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then
if [ $NVM_IS_20_17_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 21.0.0; then
NVM_IS_21_OR_ABOVE=1
fi
local NVM_IS_22_9_OR_ABOVE
NVM_IS_22_9_OR_ABOVE=0
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 22.9.0; then
NVM_IS_22_9_OR_ABOVE=1
fi
@ -420,7 +420,7 @@ nvm_install_latest_npm() {
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
$NVM_NPM_CMD install -g npm@9
elif \
[ $NVM_IS_20_17_or_ABOVE -eq 0 ] \
[ $NVM_IS_20_17_OR_ABOVE -eq 0 ] \
|| { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \
; then
nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`'