Refactor so "finding .nvmrc" can be done in a bash function.
parent
a69eae10e3
commit
66455f7c77
13
nvm.sh
13
nvm.sh
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue