Refactor `nvm_source` a bit.

master
Jordan Harband 2014-12-28 15:54:09 -08:00
parent 4708cc73ef
commit fd2fb24b03
1 changed files with 13 additions and 16 deletions

View File

@ -22,10 +22,6 @@ nvm_source() {
NVM_METHOD="$1"
if [ -z "$NVM_SOURCE" ]; then
local NVM_SOURCE
else
echo "$NVM_SOURCE"
return 0
fi
if [ "_$NVM_METHOD" = "_script" ]; then
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm.sh"
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
@ -36,6 +32,7 @@ nvm_source() {
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
return 1
fi
fi
echo "$NVM_SOURCE"
return 0
}
@ -67,7 +64,7 @@ install_nvm_from_git() {
echo "=> Downloading nvm from git to '$NVM_DIR'"
printf "\r=> "
mkdir -p "$NVM_DIR"
git clone "$(nvm_source "git")" "$NVM_DIR"
git clone "$(nvm_source git)" "$NVM_DIR"
fi
cd "$NVM_DIR" && git checkout --quiet v0.22.0 && git branch --quiet -D master >/dev/null 2>&1
return
@ -75,9 +72,9 @@ install_nvm_from_git() {
install_nvm_as_script() {
local NVM_SOURCE
NVM_SOURCE=$(nvm_source "script")
NVM_SOURCE=$(nvm_source script)
local NVM_EXEC_SOURCE
NVM_EXEC_SOURCE=$(nvm_source "script-nvm-exec")
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
# Downloading to $NVM_DIR
mkdir -p "$NVM_DIR"