Detect if curl or wget is installed

master
José Padilla 2014-03-12 09:07:48 -04:00
parent 0d44ed1126
commit 25ca41c9dc
1 changed files with 14 additions and 5 deletions

View File

@ -17,7 +17,16 @@ fi
mkdir -p "$NVM_DIR" mkdir -p "$NVM_DIR"
pushd "$NVM_DIR" > /dev/null pushd "$NVM_DIR" > /dev/null
echo -ne "=> Downloading... " echo -ne "=> Downloading... "
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed";
# Detect if curl or wget is installed to download NVM_SOURCE
if type curl > /dev/null 2>&1; then
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed";
elif type wget > /dev/null 2>&1; then
wget --quiet "$NVM_SOURCE" -O nvm.sh || fatalExit "Failed";
else
fatalExit "Must have curl or wget to install nvm";
fi
echo "Downloaded" echo "Downloaded"
popd > /dev/null popd > /dev/null
@ -26,9 +35,9 @@ if [ ! -z "$1" ]; then
PROFILE="$1" PROFILE="$1"
else else
if [ -f "$HOME/.bash_profile" ]; then if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile" PROFILE="$HOME/.bash_profile"
elif [ -f "$HOME/.profile" ]; then elif [ -f "$HOME/.profile" ]; then
PROFILE="$HOME/.profile" PROFILE="$HOME/.profile"
fi fi
fi fi
@ -36,9 +45,9 @@ SOURCE_STR="[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads NVM"
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
if [ -z $PROFILE ]; then if [ -z $PROFILE ]; then
echo "=> Profile not found" echo "=> Profile not found"
else else
echo "=> Profile $PROFILE not found" echo "=> Profile $PROFILE not found"
fi fi
echo "=> Append the following line to the correct file yourself" echo "=> Append the following line to the correct file yourself"
echo echo