Refactor `nvm_source` a bit.
parent
4708cc73ef
commit
fd2fb24b03
29
install.sh
29
install.sh
|
@ -22,19 +22,16 @@ nvm_source() {
|
||||||
NVM_METHOD="$1"
|
NVM_METHOD="$1"
|
||||||
if [ -z "$NVM_SOURCE" ]; then
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
local NVM_SOURCE
|
local NVM_SOURCE
|
||||||
else
|
if [ "_$NVM_METHOD" = "_script" ]; then
|
||||||
echo "$NVM_SOURCE"
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm.sh"
|
||||||
return 0
|
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
||||||
fi
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm-exec"
|
||||||
if [ "_$NVM_METHOD" = "_script" ]; then
|
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm.sh"
|
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||||
elif [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
|
else
|
||||||
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.22.0/nvm-exec"
|
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
||||||
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
|
return 1
|
||||||
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
fi
|
||||||
else
|
|
||||||
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
echo "$NVM_SOURCE"
|
echo "$NVM_SOURCE"
|
||||||
return 0
|
return 0
|
||||||
|
@ -67,7 +64,7 @@ install_nvm_from_git() {
|
||||||
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
||||||
printf "\r=> "
|
printf "\r=> "
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
git clone "$(nvm_source "git")" "$NVM_DIR"
|
git clone "$(nvm_source git)" "$NVM_DIR"
|
||||||
fi
|
fi
|
||||||
cd "$NVM_DIR" && git checkout --quiet v0.22.0 && git branch --quiet -D master >/dev/null 2>&1
|
cd "$NVM_DIR" && git checkout --quiet v0.22.0 && git branch --quiet -D master >/dev/null 2>&1
|
||||||
return
|
return
|
||||||
|
@ -75,9 +72,9 @@ install_nvm_from_git() {
|
||||||
|
|
||||||
install_nvm_as_script() {
|
install_nvm_as_script() {
|
||||||
local NVM_SOURCE
|
local NVM_SOURCE
|
||||||
NVM_SOURCE=$(nvm_source "script")
|
NVM_SOURCE=$(nvm_source script)
|
||||||
local NVM_EXEC_SOURCE
|
local NVM_EXEC_SOURCE
|
||||||
NVM_EXEC_SOURCE=$(nvm_source "script-nvm-exec")
|
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
|
||||||
|
|
||||||
# Downloading to $NVM_DIR
|
# Downloading to $NVM_DIR
|
||||||
mkdir -p "$NVM_DIR"
|
mkdir -p "$NVM_DIR"
|
||||||
|
|
Loading…
Reference in New Issue