made NVM_DIR and NVM_SOURCE configurable using environment variables

master
Koen Punt 2013-12-22 18:23:59 +01:00
parent fcc00b22b7
commit d2422a623a
1 changed files with 11 additions and 4 deletions

View File

@ -2,7 +2,13 @@
set -e set -e
if [ ! "$NVM_SOURCE" ]; then
NVM_SOURCE="https://github.com/creationix/nvm.git"
fi
if [ ! "$NVM_DIR" ]; then
NVM_DIR="$HOME/.nvm" NVM_DIR="$HOME/.nvm"
fi
if ! hash git 2>/dev/null; then if ! hash git 2>/dev/null; then
echo >&2 "You need to install git - visit http://git-scm.com/downloads" echo >&2 "You need to install git - visit http://git-scm.com/downloads"
@ -12,11 +18,12 @@ fi
if [ -d "$NVM_DIR" ]; then if [ -d "$NVM_DIR" ]; then
echo "=> NVM is already installed in $NVM_DIR, trying to update" echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -ne "\r=> " echo -e "\r=> \c"
cd $NVM_DIR && git pull cd "$NVM_DIR" && git pull
else else
# Cloning to $NVM_DIR # Cloning to $NVM_DIR
git clone https://github.com/creationix/nvm.git $NVM_DIR mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
fi fi
echo echo