Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add curl --max-time #771

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# log <type> <msg>
#


log() {
printf " ${SGR_CYAN}%10s${SGR_RESET} : ${SGR_FAINT}%s${SGR_RESET}\n" "$1" "$2"
}
Expand Down Expand Up @@ -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.
Expand All @@ -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"
Expand Down