Merge pull request #444 from creationix/fix_nvm_ls

Make sure `nvm ls foo` returns a nonzero exit code when a version is not found
master
Jordan Harband 2014-06-26 17:04:09 -07:00
commit 60fec40613
2 changed files with 13 additions and 2 deletions

8
nvm.sh
View File

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

View File

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