Refactor `nvm_source` a bit.
parent
4708cc73ef
commit
fd2fb24b03
29
install.sh
29
install.sh
|
@ -22,19 +22,16 @@ 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
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm-exec"
|
||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||
else
|
||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||
return 1
|
||||
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
|
||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm-exec"
|
||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||
else
|
||||
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"
|
||||
|
|
Loading…
Reference in New Issue