mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 09:31:51 +00:00
Compare commits
4 Commits
ca800fb5c1
...
2da36e8d62
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2da36e8d62 | ||
![]() |
759f70f196 | ||
![]() |
06a9179309 | ||
![]() |
996ae54fde |
@ -106,7 +106,7 @@ nvm_node_version() {
|
|||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has "curl"; then
|
if nvm_has "curl"; then
|
||||||
curl --fail --compressed -q "$@"
|
command curl --fail --compressed -q "$@"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
51
nvm.sh
51
nvm.sh
@ -101,7 +101,7 @@ nvm_get_latest() {
|
|||||||
if nvm_curl_use_compression; then
|
if nvm_curl_use_compression; then
|
||||||
CURL_COMPRESSED_FLAG="--compressed"
|
CURL_COMPRESSED_FLAG="--compressed"
|
||||||
fi
|
fi
|
||||||
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S https://latest.nvm.sh -o /dev/null)"
|
NVM_LATEST_URL="$(command curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S https://latest.nvm.sh -o /dev/null)"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
NVM_LATEST_URL="$(wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
NVM_LATEST_URL="$(wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
else
|
else
|
||||||
@ -133,18 +133,20 @@ nvm_download() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
NVM_DOWNLOAD_ARGS="${NVM_DOWNLOAD_ARGS} \"$arg\""
|
NVM_DOWNLOAD_ARGS="${NVM_DOWNLOAD_ARGS} \"$arg\""
|
||||||
done
|
done
|
||||||
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
eval "command curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(nvm_echo "$@" | command sed "
|
||||||
-e 's/--compressed //' \
|
s/--progress-bar /--progress=bar /
|
||||||
-e 's/--fail //' \
|
s/--compressed //
|
||||||
-e 's/-L //' \
|
s/--fail //
|
||||||
-e 's/-I /--server-response /' \
|
s/-L //
|
||||||
-e 's/-s /-q /' \
|
s/-I /--server-response /
|
||||||
-e 's/-sS /-nv /' \
|
s/-s /-q /
|
||||||
-e 's/-o /-O /' \
|
s/-sS /-nv /
|
||||||
-e 's/-C - /-c /')
|
s/-o /-O /
|
||||||
|
s/-C - /-c /
|
||||||
|
")
|
||||||
|
|
||||||
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
||||||
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
||||||
@ -1413,11 +1415,11 @@ nvm_add_iojs_prefix() {
|
|||||||
nvm_strip_iojs_prefix() {
|
nvm_strip_iojs_prefix() {
|
||||||
local NVM_IOJS_PREFIX
|
local NVM_IOJS_PREFIX
|
||||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||||
if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then
|
|
||||||
nvm_echo
|
case "${1-}" in
|
||||||
else
|
"${NVM_IOJS_PREFIX}") nvm_echo ;;
|
||||||
nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}"
|
*) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;;
|
||||||
fi
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls() {
|
nvm_ls() {
|
||||||
@ -1549,12 +1551,15 @@ nvm_ls() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
||||||
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
|
case "${PATTERN}" in
|
||||||
VERSIONS="${VERSIONS}
|
'' | v)
|
||||||
|
VERSIONS="${VERSIONS}
|
||||||
system"
|
system"
|
||||||
elif [ "${PATTERN}" = 'system' ]; then
|
;;
|
||||||
VERSIONS="system"
|
system)
|
||||||
fi
|
VERSIONS="system"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${VERSIONS}" ]; then
|
if [ -z "${VERSIONS}" ]; then
|
||||||
@ -1688,7 +1693,7 @@ EOF
|
|||||||
LTS="${LTS#lts/}"
|
LTS="${LTS#lts/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
VERSIONS="$( { command awk -v lts="${LTS-}" '{
|
||||||
if (!$1) { next }
|
if (!$1) { next }
|
||||||
if (lts && $10 ~ /^\-?$/) { next }
|
if (lts && $10 ~ /^\-?$/) { next }
|
||||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
||||||
@ -2732,7 +2737,7 @@ nvm_npm_global_modules() {
|
|||||||
local NPMLIST
|
local NPMLIST
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY')
|
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed -e '1d' -e '/UNMET PEER DEPENDENCY/d')
|
||||||
|
|
||||||
local INSTALLS
|
local INSTALLS
|
||||||
INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
|
INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user