From 1eee505b0c908e6296f38d5632e2b466892d5085 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 10 Mar 2017 01:07:16 +0800 Subject: [PATCH] [New] Support `--no-progress` for `nvm install`, close #1079 --- nvm.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nvm.sh b/nvm.sh index d6dd7511de1..8367d02b24a 100755 --- a/nvm.sh +++ b/nvm.sh @@ -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/-s /-nv -q /' \ -e 's/-o /-O /' \ -e 's/-C - /-c /') # shellcheck disable=SC2086 @@ -1586,10 +1586,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 [ "${NVM_NO_PROGRESS}" = "1" ]; then + PROGRESS_BAR="-s" + 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 @@ -1748,7 +1754,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 @@ -2273,8 +2279,9 @@ nvm() { version_not_provided=1 fi - local nobinary + local nobinary noprogress nobinary=0 + noprogress=0 local LTS while [ $# -ne 0 ] do @@ -2288,6 +2295,10 @@ nvm() { nvm_get_make_jobs "$1" shift # consume job count ;; + --no-progress) + noprogress=1 + shift + ;; --lts) LTS='*' shift @@ -2449,7 +2460,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="${noprogress}" nvm_install_binary "${FLAVOR}" std "${VERSION}"; then NVM_INSTALL_SUCCESS=true fi fi @@ -2458,7 +2469,7 @@ nvm() { nvm_get_make_jobs fi - if nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then + if NVM_NO_PROGRESS="${noprogress}" nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then NVM_INSTALL_SUCCESS=true fi fi