From 74cc1eb022837de493cfee649a18fcdc2a1e55c5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 7 Jul 2014 10:04:20 -0700 Subject: [PATCH] Make `nvm_curl` do a runtime check if `curl` is available. --- install.sh | 19 +++++++++---------- nvm.sh | 16 +++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index a9f88ed..e86cd4a 100755 --- a/install.sh +++ b/install.sh @@ -11,22 +11,21 @@ if [ -z "$NVM_DIR" ]; then NVM_DIR="$HOME/.nvm" fi -if nvm_has "curl"; then - nvm_curl() { +nvm_curl() { + if nvm_has "curl"; then curl $* - } -elif nvm_has "wget"; then - # Emulate curl with wget - nvm_curl() { - ARGS="$* " + elif nvm_has "wget"; then + # Emulate curl with wget + ARGS="$*" ARGS=${ARGS/--progress-bar /} ARGS=${ARGS/-L /} + ARGS=${ARGS/-I /} ARGS=${ARGS/-s /-q } ARGS=${ARGS/-o /-O } ARGS=${ARGS/-C /-c } - wget "$ARGS" - } -fi + wget $ARGS + fi +} install_nvm_from_git() { if [ -z "$NVM_SOURCE" ]; then diff --git a/nvm.sh b/nvm.sh index b6a12dd..e0a30aa 100644 --- a/nvm.sh +++ b/nvm.sh @@ -12,14 +12,12 @@ nvm_has() { return $? } -if nvm_has "curl"; then - nvm_curl() { +nvm_curl() { + if nvm_has "curl"; then curl $* - } -elif nvm_has "wget"; then - # Emulate curl with wget - nvm_curl() { - ARGS="$* " + elif nvm_has "wget"; then + # Emulate curl with wget + ARGS="$*" ARGS=${ARGS/--progress-bar /} ARGS=${ARGS/-L /} ARGS=${ARGS/-I /} @@ -27,8 +25,8 @@ elif nvm_has "wget"; then ARGS=${ARGS/-o /-O } ARGS=${ARGS/-C /-c } wget "$ARGS" - } -fi + fi +} # Make zsh glob matching behave same as bash # This fixes the "zsh: no matches found" errors