master
parent
cf5bfecec4
commit
63f72b37df
|
@ -11,7 +11,7 @@ if [ -z "$NVM_DIR" ]; then
|
||||||
NVM_DIR="$HOME/.nvm"
|
NVM_DIR="$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_curl() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
curl $*
|
curl $*
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
|
@ -59,7 +59,7 @@ install_nvm_as_script() {
|
||||||
else
|
else
|
||||||
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
fi
|
fi
|
||||||
nvm_curl -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
nvm_download -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
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ if [ -z "$METHOD" ]; then
|
||||||
# Autodetect install method
|
# Autodetect install method
|
||||||
if nvm_has "git"; then
|
if nvm_has "git"; then
|
||||||
install_nvm_from_git
|
install_nvm_from_git
|
||||||
elif nvm_has "nvm_curl"; then
|
elif nvm_has "nvm_download"; then
|
||||||
install_nvm_as_script
|
install_nvm_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"
|
||||||
|
@ -84,7 +84,7 @@ else
|
||||||
install_nvm_from_git
|
install_nvm_from_git
|
||||||
fi
|
fi
|
||||||
if [ "$METHOD" = "script" ]; then
|
if [ "$METHOD" = "script" ]; then
|
||||||
if ! nvm_has "nvm_curl"; then
|
if ! nvm_has "nvm_download"; 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
|
fi
|
||||||
|
|
22
nvm.sh
22
nvm.sh
|
@ -12,7 +12,7 @@ nvm_has() {
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_curl() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
curl $*
|
curl $*
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
|
@ -180,7 +180,7 @@ nvm_ls_remote() {
|
||||||
else
|
else
|
||||||
PATTERN=".*"
|
PATTERN=".*"
|
||||||
fi
|
fi
|
||||||
VERSIONS=`nvm_curl -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
VERSIONS=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
||||||
| \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`
|
||||||
|
@ -306,7 +306,7 @@ nvm() {
|
||||||
version_not_provided=0
|
version_not_provided=0
|
||||||
local provided_version
|
local provided_version
|
||||||
|
|
||||||
if ! nvm_has "nvm_curl"; then
|
if ! nvm_has "nvm_download"; then
|
||||||
echo 'nvm needs curl or wget to proceed.' >&2;
|
echo 'nvm needs curl or wget to proceed.' >&2;
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -370,14 +370,14 @@ nvm() {
|
||||||
if nvm_binary_available "$VERSION"; then
|
if nvm_binary_available "$VERSION"; then
|
||||||
t="$VERSION-$os-$arch"
|
t="$VERSION-$os-$arch"
|
||||||
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
||||||
sum=`nvm_curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | awk '{print $1}'`
|
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | awk '{print $1}'`
|
||||||
local tmpdir
|
local tmpdir
|
||||||
tmpdir="$NVM_DIR/bin/node-${t}"
|
tmpdir="$NVM_DIR/bin/node-${t}"
|
||||||
local tmptarball
|
local tmptarball
|
||||||
tmptarball="$tmpdir/node-${t}.tar.gz"
|
tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||||
if (
|
if (
|
||||||
mkdir -p "$tmpdir" && \
|
mkdir -p "$tmpdir" && \
|
||||||
nvm_curl -L -C - --progress-bar $url -o "$tmptarball" && \
|
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
rm -f "$tmptarball" && \
|
rm -f "$tmptarball" && \
|
||||||
|
@ -407,16 +407,16 @@ nvm() {
|
||||||
tmpdir="$NVM_DIR/src"
|
tmpdir="$NVM_DIR/src"
|
||||||
local tmptarball
|
local tmptarball
|
||||||
tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
||||||
if [ "`nvm_curl -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
|
if [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
|
||||||
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
||||||
sum=`nvm_curl -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | awk '{print $1}'`
|
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | awk '{print $1}'`
|
||||||
elif [ "`nvm_curl -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
|
elif [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
|
||||||
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
|
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
|
||||||
fi
|
fi
|
||||||
if (
|
if (
|
||||||
[ -n "$tarball" ] && \
|
[ -n "$tarball" ] && \
|
||||||
mkdir -p "$tmpdir" && \
|
mkdir -p "$tmpdir" && \
|
||||||
nvm_curl -L --progress-bar $tarball -o "$tmptarball" && \
|
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
|
||||||
nvm_checksum "$tmptarball" $sum && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
cd "$tmpdir/node-$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
|
@ -435,10 +435,10 @@ nvm() {
|
||||||
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
|
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
|
||||||
echo "npm requires node v0.2.3 or higher" >&2
|
echo "npm requires node v0.2.3 or higher" >&2
|
||||||
else
|
else
|
||||||
nvm_curl https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh
|
nvm_download https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
nvm_curl https://npmjs.org/install.sh -o - | clean=yes sh
|
nvm_download https://npmjs.org/install.sh -o - | clean=yes sh
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue