parent
1b14e6b4d9
commit
e7b42198b4
2
nvm.sh
2
nvm.sh
|
@ -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
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
unset VERSION1 VERSION2 VERSION3
|
||||
rm .nvmrc
|
||||
}
|
||||
|
||||
\. ../../nvm.sh
|
||||
|
||||
# normal .nvmrc
|
||||
printf '0.999.0\n' > .nvmrc
|
||||
nvm_rc_version
|
||||
VERSION1="${NVM_RC_VERSION}"
|
||||
|
||||
# .nvmrc with CR char
|
||||
printf '0.999.0\r\n' > .nvmrc
|
||||
nvm_rc_version
|
||||
VERSION2="${NVM_RC_VERSION}"
|
||||
|
||||
[ "${VERSION1}" = "${VERSION2}" ]
|
||||
|
||||
# .nvmrc without any newline char
|
||||
printf '0.999.0' > .nvmrc
|
||||
nvm_rc_version
|
||||
VERSION3="${NVM_RC_VERSION}"
|
||||
|
||||
[ "${VERSION1}" = "${VERSION3}" ]
|
||||
|
||||
cleanup
|
Loading…
Reference in New Issue