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

Code before:
      done

      if [ -n "${NVM_LTS-}" ]; then
        VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"
      elif [ -z "${PROVIDED_VERSION-}" ]; then
        NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version
        if [ -n "${NVM_RC_VERSION-}" ]; then
          PROVIDED_VERSION="${NVM_RC_VERSION}"
          IS_VERSION_FROM_NVMRC=1
          VERSION="$(nvm_version "${PROVIDED_VERSION}")"
        fi
        unset NVM_RC_VERSION
        if [ -z "${VERSION}" ]; then
          nvm_err 'Please see `nvm --help` or https://github.com/nvm-sh/nvm#nvmrc for more information.'
          return 127
        fi
      else
        VERSION="$(nvm_match_version "${PROVIDED_VERSION}")"
      fi

      if [ -z "${VERSION}" ]; then
        >&2 nvm --help
        return 127
      fi
      NVMRC_SAVE_TEXT=''
      if [ "$NVM_WRITE_TO_NVMRC" = true ] && [ ! "_${VERSION}" = "_∞" ] && [ ! "${VERSION}" = 'N/A' ]; then
        echo "$VERSION" > "$PWD"/.nvmrc
        NVMRC_SAVE_TEXT=" (saved to .nvmrc)"
        unset NVM_WRITE_TO_NVMRC
      fi
      if [ "_${VERSION}" = '_system' ]; then
        if nvm_has_system_node && nvm deactivate "${NVM_SILENT_ARG-}" >/dev/null 2>&1; then
          if [ "${NVM_SILENT:-0}" -ne 1 ]; then
            nvm_echo "Now using system version of node: $(node -v 2>/dev/null)$(nvm_print_npm_version)$NVMRC_SAVE_TEXT"
          fi
          return
        elif nvm_has_system_iojs && nvm deactivate "${NVM_SILENT_ARG-}" >/dev/null 2>&1; then
          if [ "${NVM_SILENT:-0}" -ne 1 ]; then
            nvm_echo "Now using system version of io.js: $(iojs --version 2>/dev/null)$(nvm_print_npm_version)"
          fi
          return
        elif [ "${NVM_SILENT:-0}" -ne 1 ]; then
          nvm_err 'System version of node not found.'
        fi
        return 127
      elif [ "_${VERSION}" = "_∞" ]; then
        if [ "${NVM_SILENT:-0}" -ne 1 ]; then
          nvm_err "The alias \"${PROVIDED_VERSION}\" leads to an infinite loop. Aborting."
        fi
        return 8
      fi

Review comment (suggestion):
```suggestion
      if [ "${NVM_WRITE_TO_NVMRC}" = true ] && [ "${VERSION}" != '∞'  ] && [ "${VERSION}" != 'N/A' ]; then
```

Code after:
        else
          EXIT_CODE=-1
        fi

        if [ $EXIT_CODE -ne 0 ]; then
          if [ -z "${NVM_MAKE_JOBS-}" ]; then
            nvm_get_make_jobs
          fi

          if [ "_${NVM_OS}" = "_win" ]; then
            nvm_err 'Installing from source on non-WSL Windows is not supported'
            EXIT_CODE=87
          else
            NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
            EXIT_CODE=$?
          fi
        fi
      fi

      if [ $EXIT_CODE -eq 0 ] && nvm_use_if_needed "${VERSION}" && nvm_install_npm_if_needed "${VERSION}"; then
        if [ -n "${LTS-}" ]; then
          nvm_ensure_default_set "lts/${LTS}"
        else
          nvm_ensure_default_set "${provided_version}"
        fi
        if [ "${NVM_UPGRADE_NPM}" = 1 ]; then
          nvm install-latest-npm
          EXIT_CODE=$?
        fi
        if [ $EXIT_CODE -eq 0 ] && [ -z "${SKIP_DEFAULT_PACKAGES-}" ]; then
          nvm_install_default_packages
        fi
        if [ $EXIT_CODE -eq 0 ] && [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_${REINSTALL_PACKAGES_FROM}" != "_N/A" ]; then
          nvm reinstall-packages "${REINSTALL_PACKAGES_FROM}"
          EXIT_CODE=$?
        fi
      else
        EXIT_CODE=$?
      fi

      return $EXIT_CODE
    ;;
    "uninstall")
      if [ $# -ne 1 ]; then
        >&2 nvm --help
        return 127
      fi

      local PATTERN
      PATTERN="${1-}"
      case "${PATTERN-}" in