Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
        VERSION_PATH="$(nvm_version_path "${VERSION}")"
        local EXIT_CODE
        "${NVM_INSTALL_THIRD_PARTY_HOOK}" "${VERSION}" "${FLAVOR}" std "${NVM_METHOD_PREFERENCE}" "${VERSION_PATH}" || {
          EXIT_CODE=$?
          nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var failed to install! ***'
          return $EXIT_CODE
        }
        if ! nvm_is_version_installed "${VERSION}"; then
          nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var claimed to succeed, but failed to install! ***'
          return 33
        fi
        EXIT_CODE=0
      else

        if [ "_$NVM_OS" = "_freebsd" ]; then
          # node.js and io.js do not have a FreeBSD binary
          nobinary=1
          nvm_err "Currently, there is no binary for $NVM_OS"
        elif [ "_$NVM_OS" = "_sunos" ]; then
          # Not all node/io.js versions have a Solaris binary
            if ! nvm_has_solaris_binary "$VERSION"; then
              nobinary=1
              nvm_err "Currently, there is no binary of version $VERSION for $NVM_OS"
          fi
        fi

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

          nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
          EXIT_CODE=$?
        fi

      fi

      if [ "$EXIT_CODE" -eq 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"
          EXIT_CODE=$?
        fi
      fi
      return $EXIT_CODE

Review comment (suggestion):
if we're going to do this check, we should set it to `-1` initially, or else `set -u` might complain.

Code after:
        }
        if ! nvm_is_version_installed "${VERSION}"; then
          nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var claimed to succeed, but failed to install! ***'
          return 33
        fi
        EXIT_CODE=0
      else

        if [ "_$NVM_OS" = "_freebsd" ]; then
          # node.js and io.js do not have a FreeBSD binary
          nobinary=1
          nvm_err "Currently, there is no binary for $NVM_OS"
        elif [ "_$NVM_OS" = "_sunos" ]; then
          # Not all node/io.js versions have a Solaris binary
            if ! nvm_has_solaris_binary "$VERSION"; then
              nobinary=1
              nvm_err "Currently, there is no binary of version $VERSION for $NVM_OS"
          fi
        fi

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

          nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
          EXIT_CODE=$?
        fi

      fi

      if [ "$EXIT_CODE" -eq 0 ] && nvm use "$VERSION"; then
        if [ -n "${LTS-}" ]; then
          nvm_ensure_default_set "lts/${LTS}"
        else
          nvm_ensure_default_set "$provided_version"
        fi
        if [ ! -z "$REINSTALL_PACKAGES_FROM" ] \
          && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
          nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
          EXIT_CODE=$?
        fi
      fi
      return $EXIT_CODE
    ;;
    "uninstall" )