Skip to content

Commit

Permalink
[New] Support --no-progress for nvm install, close nvm-sh#1079
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Mar 18, 2017
1 parent 1e6b5ce commit f0689cf
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ nvm_download() {
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-sS /-nv /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
# shellcheck disable=SC2086
Expand Down Expand Up @@ -1569,10 +1569,16 @@ nvm_install_binary() {
local TMPDIR
local VERSION_PATH

local PROGRESS_BAR
local NODE_OR_IOJS
if [ "${FLAVOR}" = 'node' ]; then
NODE_OR_IOJS="${FLAVOR}"
fi
if [ -n "${NVM_NO_PROGRESS}" ]; then
PROGRESS_BAR="-sS"
else
PROGRESS_BAR="--progress-bar"
fi
nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
TARBALL="$(nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
if [ -f "${TARBALL}" ]; then
Expand Down Expand Up @@ -1731,7 +1737,7 @@ nvm_download_artifact() {
command rm -rf "${TARBALL}"
fi
nvm_err "Downloading ${TARBALL_URL}..."
nvm_download -L -C - --progress-bar "${TARBALL_URL}" -o "${TARBALL}" || (
nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || (
command rm -rf "${TARBALL}" "${tmpdir}"
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
return 4
Expand Down Expand Up @@ -2257,6 +2263,7 @@ nvm() {
fi

local nobinary
local noprogress
nobinary=0
local LTS
while [ $# -ne 0 ]
Expand All @@ -2271,6 +2278,10 @@ nvm() {
nvm_get_make_jobs "$1"
shift # consume job count
;;
--no-progress)
noprogress=1
shift
;;
--lts)
LTS='*'
shift
Expand Down Expand Up @@ -2432,7 +2443,7 @@ nvm() {

# skip binary install if "nobinary" option specified.
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
if nvm_install_binary "${FLAVOR}" std "${VERSION}"; then
if NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_binary "${FLAVOR}" std "${VERSION}"; then
NVM_INSTALL_SUCCESS=true
fi
fi
Expand All @@ -2441,7 +2452,7 @@ nvm() {
nvm_get_make_jobs
fi

if nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then
if NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then
NVM_INSTALL_SUCCESS=true
fi
fi
Expand Down

0 comments on commit f0689cf

Please sign in to comment.