[refactor] `nvm run`: call through to `nvm exec` to remove redundant code

Jordan Harband 2016-05-04 00:58:12 -07:00
parent a69f9a8898
commit ab49a5b0c3
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 3 additions and 18 deletions

21
nvm.sh
View File

@ -2164,7 +2164,6 @@ nvm() {
local ARGS local ARGS
ARGS="$@" ARGS="$@"
local OUTPUT
local EXIT_CODE local EXIT_CODE
local ZHS_HAS_SHWORDSPLIT_UNSET local ZHS_HAS_SHWORDSPLIT_UNSET
@ -2175,29 +2174,15 @@ nvm() {
fi fi
if [ "_$VERSION" = "_N/A" ]; then if [ "_$VERSION" = "_N/A" ]; then
nvm_ensure_version_installed "$provided_version" nvm_ensure_version_installed "$provided_version"
EXIT_CODE=$?
elif [ -z "$ARGS" ]; then
if [ "$NVM_IOJS" = true ]; then
nvm exec "${NVM_SILENT-}" "$VERSION" iojs
else
nvm exec "${NVM_SILENT-}" "$VERSION" node
fi
EXIT_CODE="$?"
elif [ "$NVM_IOJS" = true ]; then elif [ "$NVM_IOJS" = true ]; then
[ -n "${NVM_SILENT-}" ] || echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)" nvm exec "${NVM_SILENT-}" "$VERSION" iojs $ARGS
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs $ARGS)"
EXIT_CODE="$?"
else else
[ -n "${NVM_SILENT-}" ] || echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)" nvm exec "${NVM_SILENT-}" "$VERSION" node $ARGS
OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)"
EXIT_CODE="$?"
fi fi
EXIT_CODE="$?"
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
unsetopt shwordsplit unsetopt shwordsplit
fi fi
if [ -n "$OUTPUT" ]; then
echo "$OUTPUT"
fi
return $EXIT_CODE return $EXIT_CODE
;; ;;
"exec" ) "exec" )