Add an `nvm_ls_current` function.

master
Jordan Harband 2014-07-14 11:29:24 -07:00
parent 8f66273922
commit 7171cbed6f
1 changed files with 6 additions and 2 deletions

8
nvm.sh
View File

@ -138,13 +138,17 @@ nvm_binary_available() {
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ] [ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
} }
nvm_ls_current() {
echo `node -v 2>/dev/null`
}
nvm_ls() { nvm_ls() {
local PATTERN local PATTERN
PATTERN=$1 PATTERN=$1
local VERSIONS local VERSIONS
VERSIONS='' VERSIONS=''
if [ "$PATTERN" = 'current' ]; then if [ "$PATTERN" = 'current' ]; then
echo `node -v 2>/dev/null` nvm_ls_current
return return
fi fi
@ -220,7 +224,7 @@ nvm_print_versions() {
local VERSION local VERSION
local FORMAT local FORMAT
local NVM_CURRENT local NVM_CURRENT
NVM_CURRENT=`nvm_version current` NVM_CURRENT=$(nvm_ls_current)
echo "$1" | while read VERSION; do echo "$1" | while read VERSION; do
if [ "$VERSION" = "$NVM_CURRENT" ]; then if [ "$VERSION" = "$NVM_CURRENT" ]; then
FORMAT='\033[0;32m-> %9s\033[0m' FORMAT='\033[0;32m-> %9s\033[0m'