mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
[Refactor] prefer case
over if/else chains
This commit is contained in:
parent
06a9179309
commit
759f70f196
21
nvm.sh
21
nvm.sh
@ -1415,11 +1415,11 @@ nvm_add_iojs_prefix() {
|
|||||||
nvm_strip_iojs_prefix() {
|
nvm_strip_iojs_prefix() {
|
||||||
local NVM_IOJS_PREFIX
|
local NVM_IOJS_PREFIX
|
||||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then
|
|
||||||
nvm_echo
|
case "${1-}" in
|
||||||
else
|
"${NVM_IOJS_PREFIX}") nvm_echo ;;
|
||||||
nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}"
|
*) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;;
|
||||||
fi
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls() {
|
nvm_ls() {
|
||||||
@ -1551,12 +1551,15 @@ nvm_ls() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
||||||
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
|
case "${PATTERN}" in
|
||||||
|
'' | v)
|
||||||
VERSIONS="${VERSIONS}
|
VERSIONS="${VERSIONS}
|
||||||
system"
|
system"
|
||||||
elif [ "${PATTERN}" = 'system' ]; then
|
;;
|
||||||
|
system)
|
||||||
VERSIONS="system"
|
VERSIONS="system"
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${VERSIONS}" ]; then
|
if [ -z "${VERSIONS}" ]; then
|
||||||
@ -1690,7 +1693,7 @@ EOF
|
|||||||
LTS="${LTS#lts/}"
|
LTS="${LTS#lts/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
VERSIONS="$( { command awk -v lts="${LTS-}" '{
|
||||||
if (!$1) { next }
|
if (!$1) { next }
|
||||||
if (lts && $10 ~ /^\-?$/) { next }
|
if (lts && $10 ~ /^\-?$/) { next }
|
||||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
||||||
|
Loading…
Reference in New Issue
Block a user