Compare commits

..

16 Commits

Author SHA1 Message Date
ryenus
d48dffa000 indent awk script properly 2025-03-12 16:47:31 +08:00
ryenus
a8874db9d6 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-03-12 16:47:31 +08:00
ryenus
30c5e810bc set NVM_NO_COLORS to --no-colors to disable color 2025-03-12 16:47:31 +08:00
ryenus
fe6fc5b04b rename min_ver to min for consistency 2025-03-12 16:47:31 +08:00
ryenus
8ef76acdee [test] avoid leaking temp variable 2025-03-12 16:47:31 +08:00
ryenus
b4ba55b30c 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-03-12 16:47:31 +08:00
ryenus
301cfa12d6 avoid inline initialization for ksh compatibility
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2025-03-12 16:47:31 +08:00
ryenus
c5a62d4228 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-03-12 16:47:31 +08:00
ryenus
797abf0b44 always show updates for installed versions
even if they're older than $NVM_MIN
2025-03-12 16:47:31 +08:00
ryenus
227bcdf5ac remove function ref duplication 2025-03-12 16:47:31 +08:00
ryenus
87049f38e4 prefixed versions like v18 also work 2025-03-12 16:47:31 +08:00
ryenus
9d0735dc7f rename NVM_MIN_VER to NVM_MIN
since nvm is all about versions, so no need for the explicit suffix.
2025-03-12 16:47:31 +08:00
ryenus
03aea1ad61 trim leading space in mock output due to eclint errors 2025-03-12 16:47:31 +08:00
ryenus
cabc668e48 add test for NVM_MIN_VER support
show only versions newer than NVM_MIN_VER if set
2025-03-12 16:47:31 +08:00
ryenus
90dadd0960 always list installed versions 2025-03-12 16:47:31 +08:00
ryenus
94a67893b3 show only versions newer than NVM_MIN_VER if set 2025-03-12 16:47:31 +08: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_than_or_equal_to "${NODE_VERSION}" 20.17.0; 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 20.17.0 "${NODE_VERSION}"; 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_than_or_equal_to "${NODE_VERSION}" 21.0.0; then
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; 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_than_or_equal_to "${NODE_VERSION}" 22.9.0; then
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; 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`'