Make sure `nvm ls foo` returns a nonzero exit code when a version is not found.

Fixes #440.
master
Jordan Harband 2014-06-22 11:33:26 -07:00
parent bb250b5730
commit 8349f0ff48
2 changed files with 11 additions and 2 deletions

6
nvm.sh
View File

@ -571,11 +571,13 @@ nvm() {
NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@" NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"
;; ;;
"ls" | "list" ) "ls" | "list" )
nvm_print_versions "`nvm_ls $2`" NVM_LS_OUTPUT=$(nvm_ls "$2")
NVM_LS_EXIT_CODE=$?
nvm_print_versions "$NVM_LS_OUTPUT"
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
nvm alias nvm alias
fi fi
return return $NVM_LS_EXIT_CODE && $?
;; ;;
"ls-remote" | "list-remote" ) "ls-remote" | "list-remote" )
nvm_print_versions "`nvm_ls_remote $2`" nvm_print_versions "`nvm_ls_remote $2`"

View File

@ -0,0 +1,7 @@
#!/bin/sh
. ../../nvm.sh
nvm ls nonexistent_version
[ "$?" = "3" ]