[Refactor] prefer case over if/else chains

This commit is contained in:
Jordan Harband 2025-02-04 22:45:35 -08:00
parent 06a9179309
commit 759f70f196
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56

19
nvm.sh
View File

@ -1415,11 +1415,11 @@ nvm_add_iojs_prefix() {
nvm_strip_iojs_prefix() {
local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then
nvm_echo
else
nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}"
fi
case "${1-}" in
"${NVM_IOJS_PREFIX}") nvm_echo ;;
*) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;;
esac
}
nvm_ls() {
@ -1551,12 +1551,15 @@ nvm_ls() {
fi
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
case "${PATTERN}" in
'' | v)
VERSIONS="${VERSIONS}
system"
elif [ "${PATTERN}" = 'system' ]; then
;;
system)
VERSIONS="system"
fi
;;
esac
fi
if [ -z "${VERSIONS}" ]; then