Skip to content

Commit

Permalink
[Fix] Install failed should return correct exit status, fix #1347
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Dec 9, 2016
1 parent 2af47b0 commit 8f6862f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,7 @@ nvm() {
return $?
fi

local NVM_INSTALL_SUCCESS
local NVM_INSTALL_EXIT_CODE
if [ -n "${NVM_INSTALL_THIRD_PARTY_HOOK-}" ]; then
nvm_err '** $NVM_INSTALL_THIRD_PARTY_HOOK env var set; dispatching to third-party installation method **'
local NVM_METHOD_PREFERENCE
Expand All @@ -2425,7 +2425,7 @@ nvm() {
nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var claimed to succeed, but failed to install! ***'
return 33
fi
NVM_INSTALL_SUCCESS=true
NVM_INSTALL_EXIT_CODE=0
else

if [ "_$NVM_OS" = "_freebsd" ]; then
Expand All @@ -2442,30 +2442,29 @@ nvm() {

# skip binary install if "nobinary" option specified.
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
if nvm_install_binary "${FLAVOR}" std "${VERSION}"; then
NVM_INSTALL_SUCCESS=true
fi
nvm_install_binary "${FLAVOR}" std "${VERSION}"
NVM_INSTALL_EXIT_CODE=$?
fi
if [ "$NVM_INSTALL_SUCCESS" != true ]; then
if [ "$NVM_INSTALL_EXIT_CODE" != 0 ]; then
if [ -z "${NVM_MAKE_JOBS-}" ]; then
nvm_get_make_jobs
fi

if nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then
NVM_INSTALL_SUCCESS=true
fi
nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
NVM_INSTALL_EXIT_CODE=$?
fi

fi

if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
if [ "$NVM_INSTALL_EXIT_CODE" = 0 ] && nvm use "$VERSION"; then
nvm_ensure_default_set "$provided_version"
if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
&& [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
NVM_INSTALL_EXIT_CODE=$?
fi
fi
return $?
return "${NVM_INSTALL_EXIT_CODE}"
;;
"uninstall" )
if [ $# -ne 1 ]; then
Expand Down

0 comments on commit 8f6862f

Please sign in to comment.