diff --git a/README.md b/README.md index b1d10604..985a7beb 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,7 @@ In brief: - `N_MAX_REMOTE_MATCHES` to change the default `ls-remote` maximum of 20 matching versions - `N_PRESERVE_NPM`: See [Preserving npm](#preserving-npm) - `N_PRESERVE_COREPACK`: See [Preserving npm](#preserving-npm) +- `N_CURL_MAX_TIMEOUT`: See curl **--max-time** ## How It Works diff --git a/bin/n b/bin/n index 2a877c45..868feeb5 100755 --- a/bin/n +++ b/bin/n @@ -6,6 +6,7 @@ # log # + log() { printf " ${SGR_CYAN}%10s${SGR_RESET} : ${SGR_FAINT}%s${SGR_RESET}\n" "$1" "$2" } @@ -80,6 +81,9 @@ N_NODE_DOWNLOAD_MIRROR=${N_NODE_DOWNLOAD_MIRROR:-https://nodejs.org/download} N_NODE_DOWNLOAD_MIRROR=${N_NODE_DOWNLOAD_MIRROR%/} readonly N_NODE_DOWNLOAD_MIRROR +N_CURL_MAX_TIMEOUT=${N_CURL_MAX_TIMEOUT:-5} +readonly N_CURL_MAX_TIMEOUT + # Using xz instead of gzip is enabled by default, if xz compatibility checks pass. # User may set N_USE_XZ to 0 to disable, or set to anything else to enable. # May also be overridden by command line flags. @@ -105,7 +109,7 @@ GET_SHOWS_PROGRESS="false" # --location to follow redirects # --fail to avoid happily downloading error page from web server for 404 et al # --show-error to show why failed (on stderr) -CURL_OPTIONS=( "--location" "--fail" "--show-error" ) +CURL_OPTIONS=( "--location" "--fail" "--show-error" "--max-time" "$N_CURL_MAX_TIMEOUT" ) if [[ -t 1 ]]; then CURL_OPTIONS+=( "--progress-bar" ) command -v curl &> /dev/null && GET_SHOWS_PROGRESS="true"