Merge f048e42002 into 8fb4ee0789
This commit is contained in:
commit
b2ffe0e4cc
18
install.sh
18
install.sh
|
|
@ -6,6 +6,10 @@ nvm_has() {
|
||||||
type "$1" > /dev/null 2>&1
|
type "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_has_http_proxy() {
|
||||||
|
[ "$NVM_HTTP_PROXY" != '' ]
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z "$NVM_DIR" ]; then
|
if [ -z "$NVM_DIR" ]; then
|
||||||
NVM_DIR="$HOME/.nvm"
|
NVM_DIR="$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
|
|
@ -42,7 +46,11 @@ nvm_source() {
|
||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
curl -q -x $NVM_HTTP_PROXY $*
|
||||||
|
else
|
||||||
curl -q $*
|
curl -q $*
|
||||||
|
fi
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
|
@ -51,7 +59,11 @@ nvm_download() {
|
||||||
-e 's/-s /-q /' \
|
-e 's/-s /-q /' \
|
||||||
-e 's/-o /-O /' \
|
-e 's/-o /-O /' \
|
||||||
-e 's/-C - /-c /')
|
-e 's/-C - /-c /')
|
||||||
wget $ARGS
|
if nvm_has_http_proxy; then
|
||||||
|
eval wget -e use_proxy=yes -e http_proxy=$NVM_HTTP_PROXY $ARGS
|
||||||
|
else
|
||||||
|
eval wget $ARGS
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +241,11 @@ nvm_do_install() {
|
||||||
local NVM_PROFILE
|
local NVM_PROFILE
|
||||||
NVM_PROFILE=$(nvm_detect_profile)
|
NVM_PROFILE=$(nvm_detect_profile)
|
||||||
|
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
SOURCE_STR="\nexport NVM_HTTP_PROXY=$NVM_HTTP_PROXY\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||||
|
else
|
||||||
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$NVM_PROFILE" ] ; then
|
if [ -z "$NVM_PROFILE" ] ; then
|
||||||
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||||
|
|
|
||||||
20
nvm.sh
20
nvm.sh
|
|
@ -22,9 +22,17 @@ nvm_is_alias() {
|
||||||
nvm_get_latest() {
|
nvm_get_latest() {
|
||||||
local NVM_LATEST_URL
|
local NVM_LATEST_URL
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
NVM_LATEST_URL="$(curl -q -x $NVM_HTTP_PROXY -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||||
|
else
|
||||||
NVM_LATEST_URL="$(curl -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
NVM_LATEST_URL="$(curl -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
|
||||||
|
fi
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
NVM_LATEST_URL="$(wget http://latest.nvm.sh -e use_proxy=yes -e http_proxy=$NVM_HTTP_PROXY --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
|
else
|
||||||
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
>&2 echo 'nvm needs curl or wget to proceed.'
|
>&2 echo 'nvm needs curl or wget to proceed.'
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -39,7 +47,11 @@ nvm_get_latest() {
|
||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
curl -q -x $NVM_HTTP_PROXY $*
|
||||||
|
else
|
||||||
curl -q $*
|
curl -q $*
|
||||||
|
fi
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
|
@ -48,8 +60,12 @@ nvm_download() {
|
||||||
-e 's/-s /-q /' \
|
-e 's/-s /-q /' \
|
||||||
-e 's/-o /-O /' \
|
-e 's/-o /-O /' \
|
||||||
-e 's/-C - /-c /')
|
-e 's/-C - /-c /')
|
||||||
|
if nvm_has_http_proxy; then
|
||||||
|
eval wget -e use_proxy=yes -e http_proxy=$NVM_HTTP_PROXY $ARGS
|
||||||
|
else
|
||||||
eval wget $ARGS
|
eval wget $ARGS
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_has_system_node() {
|
nvm_has_system_node() {
|
||||||
|
|
@ -60,6 +76,10 @@ nvm_has_system_iojs() {
|
||||||
[ "$(nvm deactivate >/dev/null 2>&1 && command -v iojs)" != '' ]
|
[ "$(nvm deactivate >/dev/null 2>&1 && command -v iojs)" != '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_has_http_proxy() {
|
||||||
|
[ "$NVM_HTTP_PROXY" != '' ]
|
||||||
|
}
|
||||||
|
|
||||||
nvm_print_npm_version() {
|
nvm_print_npm_version() {
|
||||||
if nvm_has "npm"; then
|
if nvm_has "npm"; then
|
||||||
echo " (npm v$(npm --version 2>/dev/null))"
|
echo " (npm v$(npm --version 2>/dev/null))"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
! nvm_has_http_proxy || die 'nvm_has_http_proxy: no http_proxy defined'
|
||||||
|
|
||||||
|
NVM_HTTP_PROXY=127.0.0.1:1234
|
||||||
|
nvm_has_http_proxy || die 'nvm_has_http_proxy: http_proxy defined'
|
||||||
Loading…
Reference in New Issue