mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
Merge 5e8e37a85d
into 6c3708d337
This commit is contained in:
commit
88e02ef30b
16
install.sh
16
install.sh
@ -9,10 +9,16 @@ if [ -d "$NVM_TARGET" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cloning to $NVM_TARGET
|
# Allow for alternate NVM sources so we can use a local copy or a fork
|
||||||
git clone git://github.com/creationix/nvm.git $NVM_TARGET
|
if [ ! -d "$NVM_GIT_SOURCE" ]; then
|
||||||
|
export NVM_GIT_SOURCE="git://github.com/creationix/nvm.git"
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
|
||||||
|
# Cloning to $NVM_TARGET
|
||||||
|
git clone $NVM_GIT_SOURCE $NVM_TARGET
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
# Detect profile file, .bash_profile has precedence over .profile
|
# Detect profile file, .bash_profile has precedence over .profile
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
@ -28,7 +34,7 @@ fi
|
|||||||
SOURCE_STR="[[ -s "$NVM_TARGET/nvm.sh" ]] && . "$NVM_TARGET/nvm.sh" # This loads NVM"
|
SOURCE_STR="[[ -s "$NVM_TARGET/nvm.sh" ]] && . "$NVM_TARGET/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"
|
||||||
@ -36,7 +42,7 @@ if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
|||||||
echo "=> Append the following line to the correct file yourself"
|
echo "=> Append the following line to the correct file yourself"
|
||||||
echo
|
echo
|
||||||
echo -e "\t$SOURCE_STR"
|
echo -e "\t$SOURCE_STR"
|
||||||
echo
|
echo
|
||||||
echo "=> Close and reopen your terminal to start using NVM"
|
echo "=> Close and reopen your terminal to start using NVM"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
20
nvm.sh
20
nvm.sh
@ -10,6 +10,10 @@ if [ ! -d "$NVM_DIR" ]; then
|
|||||||
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}) && pwd)
|
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}) && pwd)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$NODEJS_MIRROR" ]; then
|
||||||
|
export NODEJS_MIRROR="http://nodejs.org/"
|
||||||
|
fi
|
||||||
|
|
||||||
# Make zsh glob matching behave same as bash
|
# Make zsh glob matching behave same as bash
|
||||||
# This fixes the "zsh: no matches found" errors
|
# This fixes the "zsh: no matches found" errors
|
||||||
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
|
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
|
||||||
@ -90,7 +94,7 @@ nvm_ls_remote()
|
|||||||
else
|
else
|
||||||
PATTERN=".*"
|
PATTERN=".*"
|
||||||
fi
|
fi
|
||||||
VERSIONS=`curl -s http://nodejs.org/dist/ \
|
VERSIONS=`curl -s $NODEJS_MIRROR/dist/ \
|
||||||
| egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
| egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||||
| grep -w "${PATTERN}" \
|
| grep -w "${PATTERN}" \
|
||||||
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||||
@ -242,8 +246,8 @@ nvm()
|
|||||||
esac
|
esac
|
||||||
if [ $binavail -eq 1 ]; then
|
if [ $binavail -eq 1 ]; then
|
||||||
t="$VERSION-$os-$arch"
|
t="$VERSION-$os-$arch"
|
||||||
url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz"
|
url="$NODEJS_MIRROR/dist/$VERSION/node-${t}.tar.gz"
|
||||||
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | grep node-${t}.tar.gz | awk '{print $1}'`
|
sum=`curl -s $NODEJS_MIRROR/dist/$VERSION/SHASUMS.txt | grep node-${t}.tar.gz | awk '{print $1}'`
|
||||||
if (
|
if (
|
||||||
mkdir -p "$NVM_DIR/bin/node-${t}" && \
|
mkdir -p "$NVM_DIR/bin/node-${t}" && \
|
||||||
cd "$NVM_DIR/bin" && \
|
cd "$NVM_DIR/bin" && \
|
||||||
@ -272,11 +276,11 @@ nvm()
|
|||||||
if [ "$os" = "freebsd" ]; then
|
if [ "$os" = "freebsd" ]; then
|
||||||
make='gmake'
|
make='gmake'
|
||||||
fi
|
fi
|
||||||
if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then
|
if [ "`curl -Is "$NODEJS_MIRROR/dist/$VERSION/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then
|
||||||
tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz"
|
tarball="$NODEJS_MIRROR/dist/$VERSION/node-$VERSION.tar.gz"
|
||||||
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | grep node-$VERSION.tar.gz | awk '{print $1}'`
|
sum=`curl -s $NODEJS_MIRROR/dist/$VERSION/SHASUMS.txt | grep node-$VERSION.tar.gz | awk '{print $1}'`
|
||||||
elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then
|
elif [ "`curl -Is "$NODEJS_MIRROR/dist/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then
|
||||||
tarball="http://nodejs.org/dist/node-$VERSION.tar.gz"
|
tarball="$NODEJS_MIRROR/dist/node-$VERSION.tar.gz"
|
||||||
fi
|
fi
|
||||||
if (
|
if (
|
||||||
[ ! -z $tarball ] && \
|
[ ! -z $tarball ] && \
|
||||||
|
Loading…
Reference in New Issue
Block a user