[Fix] Improve .nvmrc reading process

Fixes #1015. Fixes #1712.
This commit is contained in:
Peter Dave Hello
2018-02-20 03:34:43 +08:00
committed by Jordan Harband
parent 1b14e6b4d9
commit e7b42198b4
2 changed files with 34 additions and 1 deletions

2
nvm.sh
View File

@@ -293,7 +293,7 @@ nvm_rc_version() {
nvm_err "No .nvmrc file found"
return 1
fi
read -r NVM_RC_VERSION < "${NVMRC_PATH}" || command printf ''
NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
if [ ! -n "${NVM_RC_VERSION}" ]; then
nvm_err "Warning: empty .nvmrc file found at \"${NVMRC_PATH}\""
return 2