Emulate curl with wget
parent
2d0c025c49
commit
5342b6a04c
33
install.sh
33
install.sh
|
@ -11,16 +11,17 @@ if [ -z "$NVM_DIR" ]; then
|
||||||
NVM_DIR="$HOME/.nvm"
|
NVM_DIR="$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_file() {
|
if ! has "curl"; then
|
||||||
# download_file source destination
|
if has "wget"; then
|
||||||
if has "curl"; then
|
# Emulate curl with wget
|
||||||
curl -s "$1" -o "$2"
|
curl() {
|
||||||
elif has "wget"; then
|
ARGS="$* "
|
||||||
wget -q "$1" -O "$2"
|
ARGS=${ARGS/-s /-q }
|
||||||
else
|
ARGS=${ARGS/-o /-O }
|
||||||
return 1
|
wget $ARGS
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
}
|
fi
|
||||||
|
|
||||||
install_from_git() {
|
install_from_git() {
|
||||||
if [ -z "$NVM_SOURCE" ]; then
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
|
@ -54,7 +55,7 @@ install_as_script() {
|
||||||
else
|
else
|
||||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
fi
|
fi
|
||||||
download_file "$NVM_SOURCE" "$NVM_DIR/nvm.sh" || {
|
curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||||
echo >&2 "Failed to download '$NVM_SOURCE'.."
|
echo >&2 "Failed to download '$NVM_SOURCE'.."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -64,7 +65,7 @@ if [ -z "$METHOD" ]; then
|
||||||
# Autodetect install method
|
# Autodetect install method
|
||||||
if has "git"; then
|
if has "git"; then
|
||||||
install_from_git
|
install_from_git
|
||||||
elif has "curl" || has "wget"; then
|
elif has "curl"; then
|
||||||
install_as_script
|
install_as_script
|
||||||
else
|
else
|
||||||
echo >&2 "You need git, curl or wget to install nvm"
|
echo >&2 "You need git, curl or wget to install nvm"
|
||||||
|
@ -72,16 +73,18 @@ if [ -z "$METHOD" ]; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$METHOD" = "git" ]; then
|
if [ "$METHOD" = "git" ]; then
|
||||||
install_from_git || {
|
if ! has "git"; then
|
||||||
echo >&2 "You need git to install nvm"
|
echo >&2 "You need git to install nvm"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
install_from_git
|
||||||
fi
|
fi
|
||||||
if [ "$METHOD" = "script" ]; then
|
if [ "$METHOD" = "script" ]; then
|
||||||
install_as_script || {
|
if ! has "curl"; then
|
||||||
echo >&2 "You need curl or wget to install nvm"
|
echo >&2 "You need curl or wget to install nvm"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
install_as_script
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue