From 25c0be1e20968b9b68dc221fb2de168b19bc80b3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 5 Jul 2014 13:51:13 -0700 Subject: [PATCH] Using an `nvm_curl` function instead of `curl`/`wget` directly. --- install.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 3879245..3cf4a0a 100755 --- a/install.sh +++ b/install.sh @@ -11,16 +11,18 @@ if [ -z "$NVM_DIR" ]; then NVM_DIR="$HOME/.nvm" fi -if ! nvm_has "curl"; then - if nvm_has "wget"; then - # Emulate curl with wget - curl() { - ARGS="$* " - ARGS=${ARGS/-s /-q } - ARGS=${ARGS/-o /-O } - wget "$ARGS" - } - fi +if nvm_has "curl"; then + nvm_curl() { + curl $* + } +elif nvm_has "wget"; then + # Emulate curl with wget + nvm_curl() { + ARGS="$* " + ARGS=${ARGS/-s /-q } + ARGS=${ARGS/-o /-O } + wget "$ARGS" + } fi install_nvm_from_git() { @@ -55,7 +57,7 @@ install_nvm_as_script() { else echo "=> Downloading nvm as script to '$NVM_DIR'" fi - curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { + nvm_curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || { echo >&2 "Failed to download '$NVM_SOURCE'.." return 1 } @@ -65,7 +67,7 @@ if [ -z "$METHOD" ]; then # Autodetect install method if nvm_has "git"; then install_nvm_from_git - elif nvm_has "curl"; then + elif nvm_has "nvm_curl"; then install_nvm_as_script else echo >&2 "You need git, curl, or wget to install nvm" @@ -80,7 +82,7 @@ else install_nvm_from_git fi if [ "$METHOD" = "script" ]; then - if ! nvm_has "curl"; then + if ! nvm_has "nvm_curl"; then echo >&2 "You need curl or wget to install nvm" exit 1 fi