Browse Source

Add support for `--silent` to `nvm run` and `nvm exec`.

Fixes #842.
Jordan Harband 10 years ago
parent
commit
eb81fba8f7
  1. 25
      nvm.sh

25
nvm.sh

@ -1285,8 +1285,8 @@ nvm() {
echo ' --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>' echo ' --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>'
echo ' nvm uninstall <version> Uninstall a version' echo ' nvm uninstall <version> Uninstall a version'
echo ' nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available' echo ' nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available'
echo ' nvm exec <version> [<command>] Run <command> on <version>. Uses .nvmrc if available for <version>' echo ' nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available'
echo ' nvm run <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available for <version>' echo ' nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available'
echo ' nvm current Display currently activated version' echo ' nvm current Display currently activated version'
echo ' nvm ls List installed versions' echo ' nvm ls List installed versions'
echo ' nvm ls <version> List versions matching a given description' echo ' nvm ls <version> List versions matching a given description'
@ -1659,6 +1659,14 @@ nvm() {
has_checked_nvmrc=0 has_checked_nvmrc=0
# run given version of node # run given version of node
shift shift
local NVM_SILENT
NVM_SILENT=0
if [ "_$1" = "_--silent" ]; then
NVM_SILENT=1
shift
fi
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
nvm_rc_version && has_checked_nvmrc=1 nvm_rc_version && has_checked_nvmrc=1
if [ -n "$NVM_RC_VERSION" ]; then if [ -n "$NVM_RC_VERSION" ]; then
@ -1713,11 +1721,11 @@ nvm() {
fi fi
EXIT_CODE="$?" EXIT_CODE="$?"
elif [ "$NVM_IOJS" = true ]; then elif [ "$NVM_IOJS" = true ]; then
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)" [ $NVM_SILENT -eq 1 ] || echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs $ARGS)" OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs $ARGS)"
EXIT_CODE="$?" EXIT_CODE="$?"
else else
echo "Running node $VERSION$(nvm_print_npm_version)" [ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm_print_npm_version)"
OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)" OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)"
EXIT_CODE="$?" EXIT_CODE="$?"
fi fi
@ -1732,6 +1740,13 @@ nvm() {
"exec" ) "exec" )
shift shift
local NVM_SILENT
NVM_SILENT=0
if [ "_$1" = "_--silent" ]; then
NVM_SILENT=1
shift
fi
local provided_version local provided_version
provided_version="$1" provided_version="$1"
if [ -n "$provided_version" ]; then if [ -n "$provided_version" ]; then
@ -1751,7 +1766,7 @@ nvm() {
return $EXIT_CODE return $EXIT_CODE
fi fi
echo "Running node $VERSION$(nvm_print_npm_version)" [ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm_print_npm_version)"
NODE_VERSION="$VERSION" $NVM_DIR/nvm-exec "$@" NODE_VERSION="$VERSION" $NVM_DIR/nvm-exec "$@"
;; ;;
"ls" | "list" ) "ls" | "list" )

Loading…
Cancel
Save