diff --git a/nvm.sh b/nvm.sh index 6dc779eb2c2..2c90e6bbd11 100644 --- a/nvm.sh +++ b/nvm.sh @@ -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 /' \ @@ -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