[Fix] `nvm-exec`: properly exit when failing; improve error messages, suppress `nvm use --help` output

Fixes #997.
Jordan Harband 2016-02-04 11:19:34 -08:00
parent 649e416017
commit 77e0449c89
1 changed files with 4 additions and 3 deletions

View File

@ -5,9 +5,10 @@ DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "$DIR/nvm.sh" --no-use
if [ -n "$NODE_VERSION" ]; then
nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127)
else
nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127)
nvm use $NODE_VERSION > /dev/null || exit 127
elif ! nvm use >/dev/null 2>&1; then
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
exit 127
fi
exec "$@"