Skip sourcing nvm.sh if it's already available

This commit is contained in:
Thomas Goyne 2017-09-18 16:19:33 -07:00
parent ada601354c
commit 5189915980
1 changed files with 10 additions and 6 deletions

View File

@ -232,12 +232,16 @@ cleanup
trap cleanup EXIT
# Use a consistent version of Node if possible.
if [ -f "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" || true
elif [ -x "$(command -v brew)" ] && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
# we must be on mac and nvm was installed with brew
# TODO: change the mac slaves to use manual nvm installation
. "$(brew --prefix nvm)/nvm.sh" || true
if [[ -z "$(command -v nvm)" ]]; then
if [ -f "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" || true
elif [ -x "$(command -v brew)" ] && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
# we must be on mac and nvm was installed with brew
# TODO: change the mac slaves to use manual nvm installation
. "$(brew --prefix nvm)/nvm.sh" || true
elif [ -f "$HOME/.nvm/nvm.sh" ]; then
. ~/.nvm/nvm.sh
fi
fi
if [[ "$(command -v nvm)" ]]; then
nvm install 6.5.0