Consolidate faster default alias lookup, and use that explicit version to avoid a second default alias lookup in `nvm use default`.

Related to #709.
master
Jordan Harband 2015-04-04 13:46:28 -07:00
parent 9fc20bb14b
commit 96e73825bd
1 changed files with 3 additions and 3 deletions

6
nvm.sh
View File

@ -1716,15 +1716,15 @@ nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ] [ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
} }
VERSION="$(nvm_alias default 2>/dev/null)"
if nvm_supports_source_options && [ "_$1" = "_--install" ]; then if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
VERSION="$(nvm_alias default 2>/dev/null)"
if [ -n "$VERSION" ]; then if [ -n "$VERSION" ]; then
nvm install "$VERSION" >/dev/null nvm install "$VERSION" >/dev/null
elif nvm_rc_version >/dev/null 2>&1; then elif nvm_rc_version >/dev/null 2>&1; then
nvm install >/dev/null nvm install >/dev/null
fi fi
elif nvm_alias default >/dev/null 2>&1; then elif [ -n "$VERSION" ]; then
nvm use default >/dev/null nvm use "$VERSION" >/dev/null
elif nvm_rc_version >/dev/null 2>&1; then elif nvm_rc_version >/dev/null 2>&1; then
nvm use >/dev/null nvm use >/dev/null
fi fi