-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[New] Support --no-progress
for nvm install
, close #1079
#1422
Conversation
nvm.sh
Outdated
local NODE_OR_IOJS | ||
if [ "${FLAVOR}" = 'node' ]; then | ||
NODE_OR_IOJS="${FLAVOR}" | ||
fi | ||
if [ "${NVM_NO_PROGRESS}" = "1" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For things like this it's best to test if the environment variable is non-zero length:
if [ -n "${NVM_NO_PROGRESS}" ]; then
...
fi
Either it exists and has content or doesn't is how I've seen it typically tested in other projects which are bash-based. I tend to like that style of testing more.
nvm.sh
Outdated
local NODE_OR_IOJS | ||
if [ "${FLAVOR}" = 'node' ]; then | ||
NODE_OR_IOJS="${FLAVOR}" | ||
fi | ||
if [ "${NVM_NO_PROGRESS}" = "1" ]; then | ||
PROGRESS_BAR="-s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use:
PROGRESS_BAR="-sS"
-s
by itself silences all output (including errors). However, I believe a user would want to know why something failed so -S
will still properly surface errors to them. -sS
will only output if there's an error.
nvm.sh
Outdated
@@ -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 /' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to other feedback I think this should be (adding -sS
and excluding -q
):
...
-e 's/-sS /-nv /'
...
You don't want -q
because it will completely disable output including errors. From the wget
man page -nv
is non-verbose but will still display errors when they occur (akin to -sS
).
nvm.sh
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to earlier comment:
if NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_source ...
nvm.sh
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might I make a recommendation here as well?
if NVM_NO_PROGRESS="${NVM_NO_PROGRESS:-${noprogress}}" nvm_install_source ...
If you look up Parameter Expansion
in the bash man page you'll find that ${VAR:-default}
will only take the default value if $VAR
is unset. The reason why this is useful is because it allows a user to set NVM_NO_PROGRESS
globally as an environment variable on their system which will always disable progress without having to use the nvm --no-progress
option. In a CI-like, environment I feel this would be desirable.
Just my two cents on environment variables and using defaults.
@ljharb do you agree with all the change requests from @samrocketman? If so, I can start to update the PR, thanks. |
@PeterDaveHello the comments look good; I'm confused why |
nvm.sh
Outdated
@@ -2273,8 +2279,9 @@ nvm() { | |||
version_not_provided=1 | |||
fi | |||
|
|||
local nobinary | |||
local nobinary noprogress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please put each local
declaration on its own separate line.
1eee505
to
dc35687
Compare
Okay I updated 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for taking the time.
dc35687
to
f0689cf
Compare
Got conflicts ... fixing now. |
6873bf0
to
8195949
Compare
Should be fixed now. |
This doesn't seem to work for me consistently in local testing. nvm install --no-progress -s 5.9.0
Downloading https://nodejs.org/dist/v5.9.0/node-v5.9.0.tar.xz...
curl: (3) <url> malformed
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
1 12.6M 1 211k 0 0 355k 0 0:00:36 --:--:-- 0:00:36 354k^C |
@ljharb can you elaborate on the versions of software you're using? Considering what is involved in this PR perhaps versions of: lsb_release -a
#alternatively instead of lsb_release: head -n1 /etc/issue
uname -rms
bash --version
curl --version
wget --version
sed --version |
8195949
to
ddb0a92
Compare
My mistake, should be fixed now. |
@samrocketman should be whatever comes stock on my Mac:
```sh
$ lsb_release -a
-bash: lsb_release: command not found
$ head -n1 /etc/issue $ uname -rms $ bash --version $ curl --version $ wget --version -cares +digest -gpgme +https +ipv6 -iri +large-file -metalink -nls Wgetrc: Copyright (C) 2015 Free Software Foundation, Inc. Originally written by Hrvoje Niksic [email protected]. $ sed --version
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now appears to work in my local testing, thanks.
Is there any way we could test this? Perhaps one test could mock out nvm_download
and assert on the presence of --progress-bar
vs -sS
, and then another test for nvm_download
itself?
I'm not sure what kind of assertion would it looks like, any suggestions? |
Take a look at |
@PeterDaveHello it'd be great to get this in soon; have you had a chance to work on these tests? |
@ljharb sorry for the delay, I'd like to, but not sure when can I finish it, no offense, but I also wonder if it's a little bit rush, would that be possible that you can directly finish the tests? |
ddb0a92
to
4d5b180
Compare
@ljharb please take a look, test added, not sure if it's good enough, thanks. |
df45148
to
dd238c1
Compare
dd238c1
to
3b3e368
Compare
Ping... (merge conflicts fixed) |
nvm.sh
Outdated
local NODE_OR_IOJS | ||
if [ "${FLAVOR}" = 'node' ]; then | ||
NODE_OR_IOJS="${FLAVOR}" | ||
fi | ||
if [ "${NVM_NO_PROGRESS-}" = "1" ]; then | ||
PROGRESS_BAR="-sS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be --silent --show-error
, or would that make combining them tricky?
Is there a reason we ever don't want --show-error
semantics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because we use parameters like -L
, -I
, -C
, so it's to maintain consistency to use a short parameter and maybe I should even use -#
instead of --progress-bar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as both forms work on the same systems, I'd prefer the long versions for readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe revise this somewhere else? Consistency is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair. We can stick to the short versions now but please add the long ones in a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this before (can't remember where). The long option is not always available in some versions of curl
. However, the short option definitely is. For compatibility, I recommend sticking to the short option for this specific feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, in that case let's stick with the short options (but comment the long ones, for clarity)
nvm.sh
Outdated
if [ "${NVM_NO_PROGRESS-}" = "1" ]; then | ||
PROGRESS_BAR="-sS" | ||
else | ||
PROGRESS_BAR="--progress-bar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is "PROGRESS_BAR", as defined here, referenced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no - I mean that lines 2017-2021 seem useless since nothing ever uses PROGRESS_BAR
in this code path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nvm_download_artifact()
will use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't use it unless it's passed or exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm ... shell's variable passing is always confusing, it looks working. I pass it anyway ;)
5d118ce
to
d9afdba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try this out locally, then merge.
d9afdba
to
113d807
Compare
Thanks for sticking it out @PeterDaveHello |
Fixes #1079