Skip to content

Commit 0f0fda7

Browse files
naomiquinonesDena Burd
authored andcommitted
[Fix] ensure --help is intercepted on any command
Co-authored-by: Naomi Quinones <[email protected]> Co-authored-by: Dena Burd <[email protected]>
1 parent a01deb1 commit 0f0fda7

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

nvm.sh

+18-11
Original file line numberDiff line numberDiff line change
@@ -2345,16 +2345,11 @@ nvm() {
23452345
return $?
23462346
fi
23472347

2348-
local COMMAND
2349-
COMMAND="${1-}"
2350-
shift
2351-
2352-
# initialize local variables
2353-
local VERSION
2354-
local ADDITIONAL_PARAMETERS
2355-
2356-
case $COMMAND in
2357-
'help' | '--help')
2348+
argsList=("$@")
2349+
for i in ${argsList[@]}
2350+
do
2351+
case $i in
2352+
'help'|'-help'|'--help')
23582353
local NVM_IOJS_PREFIX
23592354
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
23602355
local NVM_NODE_PREFIX
@@ -2434,8 +2429,20 @@ nvm() {
24342429
nvm_echo 'Note:'
24352430
nvm_echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)'
24362431
nvm_echo
2437-
;;
2432+
return 0;
2433+
;;
2434+
esac
2435+
done
2436+
2437+
local COMMAND
2438+
COMMAND="${1-}"
2439+
shift
24382440

2441+
# initialize local variables
2442+
local VERSION
2443+
local ADDITIONAL_PARAMETERS
2444+
2445+
case $COMMAND in
24392446
"cache")
24402447
case "${1-}" in
24412448
dir) nvm_cache_dir ;;
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
die () { echo "$@" ; exit 1; }
4+
5+
\. ../../../nvm.sh
6+
7+
TERM=dumb nvm clear-cache --help | grep 'Usage:' || die 'did not print help menu'
8+
TERM=dumb nvm cache help version | grep 'Usage:' || die 'did not print help menu'
9+
TERM=dumb nvm cache -help version| grep 'Usage:' || die 'did not print help menu'

0 commit comments

Comments
 (0)