nvm
nvm copied to clipboard
`nvm use` does not fully respect `--silent`
It runs nvm_rc_version, which echos "Found ..." and "Now using..."
All output should be silenced (or introduce --silence-all or nvm --quiet use or something)
That's a good point. I'm concerned, however, that using the .nvmrc file is so implicit that that output would have real value.
However, I suppose then "not using --silent" would be the recommendation?
fwiw, you can also do nvm use >/dev/null if you don't want any output.
I have no problem(the output) when I'm using nvm use 6 --silent, nvm use 4 --silent, is this still a problem here?
@peterdavehello it is only when using a .nvmrc file, not when manually setting the version
I think the semantics of --silent are not necessarily "do not output anything" - since you can use >/dev/null to actually suppress all output.
for me, I would expect the --silent flag to suppress all console output, which it still doesn't do if you're using nvm use in a directory with an .nvmrc.
I work on a project with lots of different sub modules using different versions of node, so I would like to just alias my cd command to cd $1 && nvm use --silent. That way I don't have to think about switching every time I move to a new dir.
nvm use >/dev/null produces the same console output for me. So that doesn't seem to circumvent the issue.
> /dev/null 2>&1 is how you suppress all console output in all unix commands; it wouldn't really make sense nor be part of the unix philosophy to expect that functionality to be duplicated in-project.
In other words, nvm use >/dev/null 2>&1 will suppress all output.
> /dev/null 2>&1is how you suppress all console output in all unix commands; it wouldn't really make sense nor be part of the unix philosophy to expect that functionality to be duplicated in-project.In other words,
nvm use >/dev/null 2>&1will suppress all output.
--silent/--quiet flags are still useful when you want errors to show, but otherwise suppress any other output. That's what I would expect here.
FYI for anyone coming up on this like I did, I ended up using this as a one-liner to get the node path in a given directory that uses an nvmrc:
ACTUAL_NODE_PATH=$(cd "$TARGET" > /dev/null; nvm which --silent)