[Fix] ensure `--help` is intercepted on any command

Co-authored-by: Naomi Quinones <52065567+naomiquinones@users.noreply.github.com>
Co-authored-by: Dena Burd <me@Denas-MacBook-Air.local>
Naomi Quinones 2020-08-04 16:32:19 -07:00 committed by Jordan Harband
parent a01deb11dc
commit 1bf567bd0b
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 97 additions and 82 deletions

26
nvm.sh
View File

@ -2345,16 +2345,10 @@ nvm() {
return $? return $?
fi fi
local COMMAND for i in "$@"
COMMAND="${1-}" do
shift case $i in
'-h'|'help'|'--help')
# initialize local variables
local VERSION
local ADDITIONAL_PARAMETERS
case $COMMAND in
'help' | '--help')
local NVM_IOJS_PREFIX local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
local NVM_NODE_PREFIX local NVM_NODE_PREFIX
@ -2434,8 +2428,20 @@ nvm() {
nvm_echo 'Note:' nvm_echo 'Note:'
nvm_echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)' nvm_echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)'
nvm_echo nvm_echo
return 0;
;; ;;
esac
done
local COMMAND
COMMAND="${1-}"
shift
# initialize local variables
local VERSION
local ADDITIONAL_PARAMETERS
case $COMMAND in
"cache") "cache")
case "${1-}" in case "${1-}" in
dir) nvm_cache_dir ;; dir) nvm_cache_dir ;;

View File

@ -0,0 +1,9 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
TERM=dumb nvm clear-cache --help | grep 'Usage:' || die 'did not print help menu'
TERM=dumb nvm cache help version | grep 'Usage:' || die 'did not print help menu'
TERM=dumb nvm cache -h version| grep 'Usage:' || die 'did not print help menu'