mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-07-18 21:08:23 +08:00
+1
-1
@@ -118,7 +118,7 @@ nvm_node_version() {
|
|||||||
|
|
||||||
nvm_download() {
|
nvm_download() {
|
||||||
if nvm_has_executable "curl"; then
|
if nvm_has_executable "curl"; then
|
||||||
curl --fail --compressed -q "$@"
|
command curl --fail --compressed -q "$@"
|
||||||
elif nvm_has_executable "wget"; then
|
elif nvm_has_executable "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 /' \
|
||||||
|
|||||||
@@ -113,7 +113,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_executable "wget"; then
|
elif nvm_has_executable "wget"; then
|
||||||
NVM_LATEST_URL="$(command wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
NVM_LATEST_URL="$(command wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ WORK="$PWD/nvm_get_latest-work.$$"
|
|||||||
TEST_BIN="$WORK/bin"
|
TEST_BIN="$WORK/bin"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
unset -f curl wget
|
||||||
rm -rf "$WORK"
|
rm -rf "$WORK"
|
||||||
export PATH="$OLDPATH"
|
export PATH="$OLDPATH"
|
||||||
}
|
}
|
||||||
@@ -96,6 +97,17 @@ chmod +x "$TEST_BIN/wget"
|
|||||||
|
|
||||||
export PATH="$TEST_BIN:$OLDPATH"
|
export PATH="$TEST_BIN:$OLDPATH"
|
||||||
|
|
||||||
|
# shadowing shell functions, like aliases baked into a user's shell, must be
|
||||||
|
# bypassed in favor of the executables on PATH (https://github.com/nvm-sh/nvm/issues/2923)
|
||||||
|
curl() {
|
||||||
|
echo >&2 'the shadowing curl function was called'
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
wget() {
|
||||||
|
echo >&2 'the shadowing wget function was called'
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
try nvm_get_latest
|
try nvm_get_latest
|
||||||
[ "_$CAPTURED_STDOUT" = "_$EXPECTED_VERSION" ] \
|
[ "_$CAPTURED_STDOUT" = "_$EXPECTED_VERSION" ] \
|
||||||
|| die "success path did not return version '$EXPECTED_VERSION', got '$CAPTURED_STDOUT'"
|
|| die "success path did not return version '$EXPECTED_VERSION', got '$CAPTURED_STDOUT'"
|
||||||
|
|||||||
Reference in New Issue
Block a user