[New] Support `--no-progress` for `nvm install`
Closes #1079.
parent
3fc7b737f5
commit
113d807e5a
32
nvm.sh
32
nvm.sh
|
@ -113,6 +113,7 @@ nvm_download() {
|
||||||
-e 's/-L //' \
|
-e 's/-L //' \
|
||||||
-e 's/-I /--server-response /' \
|
-e 's/-I /--server-response /' \
|
||||||
-e 's/-s /-q /' \
|
-e 's/-s /-q /' \
|
||||||
|
-e 's/-sS /-nv /' \
|
||||||
-e 's/-o /-O /' \
|
-e 's/-o /-O /' \
|
||||||
-e 's/-C - /-c /')
|
-e 's/-C - /-c /')
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
|
@ -1738,12 +1739,19 @@ nvm_install_binary() {
|
||||||
local TMPDIR
|
local TMPDIR
|
||||||
local VERSION_PATH
|
local VERSION_PATH
|
||||||
|
|
||||||
|
local PROGRESS_BAR
|
||||||
local NODE_OR_IOJS
|
local NODE_OR_IOJS
|
||||||
if [ "${FLAVOR}" = 'node' ]; then
|
if [ "${FLAVOR}" = 'node' ]; then
|
||||||
NODE_OR_IOJS="${FLAVOR}"
|
NODE_OR_IOJS="${FLAVOR}"
|
||||||
fi
|
fi
|
||||||
|
if [ "${NVM_NO_PROGRESS-}" = "1" ]; then
|
||||||
|
# --silent, --show-error, use short option as @samrocketman mentions the compatibility issue.
|
||||||
|
PROGRESS_BAR="-sS"
|
||||||
|
else
|
||||||
|
PROGRESS_BAR="--progress-bar"
|
||||||
|
fi
|
||||||
nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
|
nvm_echo "Downloading and installing ${NODE_OR_IOJS-} ${VERSION}..."
|
||||||
TARBALL="$(nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
|
TARBALL="$(PROGRESS_BAR="${PROGRESS_BAR}" nvm_download_artifact "${FLAVOR}" binary "${TYPE-}" "${VERSION}" | command tail -1)"
|
||||||
if [ -f "${TARBALL}" ]; then
|
if [ -f "${TARBALL}" ]; then
|
||||||
TMPDIR="$(dirname "${TARBALL}")/files"
|
TMPDIR="$(dirname "${TARBALL}")/files"
|
||||||
fi
|
fi
|
||||||
|
@ -1900,7 +1908,7 @@ nvm_download_artifact() {
|
||||||
command rm -rf "${TARBALL}"
|
command rm -rf "${TARBALL}"
|
||||||
fi
|
fi
|
||||||
nvm_err "Downloading ${TARBALL_URL}..."
|
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}"
|
command rm -rf "${TARBALL}" "${tmpdir}"
|
||||||
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
|
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
|
||||||
return 4
|
return 4
|
||||||
|
@ -2047,6 +2055,13 @@ nvm_install_source() {
|
||||||
local TMPDIR
|
local TMPDIR
|
||||||
local VERSION_PATH
|
local VERSION_PATH
|
||||||
|
|
||||||
|
if [ "${NVM_NO_PROGRESS-}" = "1" ]; then
|
||||||
|
# --silent, --show-error, use short option as @samrocketman mentions the compatibility issue.
|
||||||
|
PROGRESS_BAR="-sS"
|
||||||
|
else
|
||||||
|
PROGRESS_BAR="--progress-bar"
|
||||||
|
fi
|
||||||
|
|
||||||
local ZSH_HAS_SHWORDSPLIT_UNSET
|
local ZSH_HAS_SHWORDSPLIT_UNSET
|
||||||
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
||||||
if nvm_has "setopt"; then
|
if nvm_has "setopt"; then
|
||||||
|
@ -2054,7 +2069,7 @@ nvm_install_source() {
|
||||||
setopt shwordsplit
|
setopt shwordsplit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARBALL="$(nvm_download_artifact "${FLAVOR}" source "${TYPE}" "${VERSION}" | command tail -1)" && \
|
TARBALL="$(PROGRESS_BAR="${PROGRESS_BAR}" nvm_download_artifact "${FLAVOR}" source "${TYPE}" "${VERSION}" | command tail -1)" && \
|
||||||
[ -f "${TARBALL}" ] && \
|
[ -f "${TARBALL}" ] && \
|
||||||
TMPDIR="$(dirname "${TARBALL}")/files" && \
|
TMPDIR="$(dirname "${TARBALL}")/files" && \
|
||||||
if ! (
|
if ! (
|
||||||
|
@ -2366,6 +2381,7 @@ nvm() {
|
||||||
nvm_echo ' --lts=<LTS name> When installing, only select from versions for a specific LTS line'
|
nvm_echo ' --lts=<LTS name> When installing, only select from versions for a specific LTS line'
|
||||||
nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'
|
nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'
|
||||||
nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'
|
nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'
|
||||||
|
nvm_echo ' --no-progress Disable the progress bar on any downloads'
|
||||||
nvm_echo ' nvm uninstall <version> Uninstall a version'
|
nvm_echo ' nvm uninstall <version> Uninstall a version'
|
||||||
nvm_echo ' nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.'
|
nvm_echo ' nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.'
|
||||||
nvm_echo ' nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.'
|
nvm_echo ' nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.'
|
||||||
|
@ -2517,7 +2533,9 @@ nvm() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local nobinary
|
local nobinary
|
||||||
|
local noprogress
|
||||||
nobinary=0
|
nobinary=0
|
||||||
|
noprogress=0
|
||||||
local LTS
|
local LTS
|
||||||
local NVM_UPGRADE_NPM
|
local NVM_UPGRADE_NPM
|
||||||
NVM_UPGRADE_NPM=0
|
NVM_UPGRADE_NPM=0
|
||||||
|
@ -2533,6 +2551,10 @@ nvm() {
|
||||||
nvm_get_make_jobs "$1"
|
nvm_get_make_jobs "$1"
|
||||||
shift # consume job count
|
shift # consume job count
|
||||||
;;
|
;;
|
||||||
|
--no-progress)
|
||||||
|
noprogress=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--lts)
|
--lts)
|
||||||
LTS='*'
|
LTS='*'
|
||||||
shift
|
shift
|
||||||
|
@ -2741,7 +2763,7 @@ nvm() {
|
||||||
|
|
||||||
# skip binary install if "nobinary" option specified.
|
# skip binary install if "nobinary" option specified.
|
||||||
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
|
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
|
||||||
nvm_install_binary "${FLAVOR}" std "${VERSION}"
|
NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_binary "${FLAVOR}" std "${VERSION}"
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
fi
|
fi
|
||||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||||
|
@ -2749,7 +2771,7 @@ nvm() {
|
||||||
nvm_get_make_jobs
|
nvm_get_make_jobs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
|
NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
nvm cache clear
|
||||||
|
nvm deactivate
|
||||||
|
rm -rf ${NVM_DIR}/v*
|
||||||
|
nvm unalias default
|
||||||
|
}
|
||||||
|
|
||||||
|
die () { >&2 echo "$@" ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_has_colors() { return 1 ; }
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
OUTPUT="$(2>&1 nvm install --no-progress v0.12.18)"
|
||||||
|
EXPECTED_OUTPUT="Downloading and installing node v0.12.18...
|
||||||
|
Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz...
|
||||||
|
Computing checksum with sha256sum
|
||||||
|
Checksums matched!
|
||||||
|
Now using node v0.12.18 (npm v2.15.11)
|
||||||
|
Creating default alias: default -> v0.12.18 *"
|
||||||
|
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
OUTPUT="$(2>&1 nvm install v0.12.18)"
|
||||||
|
EXPECTED_OUTPUT="Downloading and installing node v0.12.18...
|
||||||
|
Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz...
|
||||||
|
######################################################################## 100.0%
|
||||||
|
Computing checksum with sha256sum
|
||||||
|
Checksums matched!
|
||||||
|
Now using node v0.12.18 (npm v2.15.11)
|
||||||
|
Creating default alias: default -> v0.12.18 *"
|
||||||
|
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
|
||||||
|
cleanup
|
Loading…
Reference in New Issue