Skip to content

Commit

Permalink
[New] Add support for NVM_AUTH_HEADER env var
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch2344 committed Jun 21, 2024
1 parent e597bb2 commit cc02c1d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,17 @@ nvm_get_latest() {

nvm_download() {
local CURL_COMPRESSED_FLAG
local AUTH_HEADER_FLAG

if [ -n "$NVM_AUTH_HEADER" ]; then
AUTH_HEADER_FLAG="--header $NVM_AUTH_HEADER"
fi

if nvm_has "curl"; then
if nvm_curl_use_compression; then
CURL_COMPRESSED_FLAG="--compressed"
fi
curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
curl --fail ${CURL_COMPRESSED_FLAG:-} ${AUTH_HEADER_FLAG:-} -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
Expand All @@ -133,6 +139,10 @@ nvm_download() {
-e 's/-sS /-nv /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')

if [ -n "$AUTH_HEADER_FLAG" ]; then
ARGS="$AUTH_HEADER_FLAG $ARGS"
fi
# shellcheck disable=SC2086
eval wget $ARGS
fi
Expand Down

0 comments on commit cc02c1d

Please sign in to comment.