Refactor so "finding .nvmrc" can be done in a bash function.

master
Jordan Harband 2014-04-28 14:48:36 -07:00
parent a69eae10e3
commit 66455f7c77
1 changed files with 10 additions and 3 deletions

13
nvm.sh
View File

@ -34,11 +34,18 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist" export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi fi
nvm_find_nvmrc() {
if [ -e '.nvmrc' ]; then
echo '.nvmrc'
fi
}
# Obtain nvm version from rc file # Obtain nvm version from rc file
nvm_rc_version() { nvm_rc_version() {
if [ -e .nvmrc ]; then local NVMRC_PATH=$(nvm_find_nvmrc)
NVM_RC_VERSION=`cat .nvmrc | head -n 1` if [ -e "$NVMRC_PATH" ]; then
echo "Found .nvmrc files with version <$NVM_RC_VERSION>" NVM_RC_VERSION=`cat "$NVMRC_PATH" | head -n 1`
echo "Found $NVMRC_PATH with version <$NVM_RC_VERSION>"
fi fi
} }