Put a star by the active version in "nvm list" and don't allow "nvm use" to set a version that isn't installed.

master
Tim Caswell 2010-04-19 10:46:58 -05:00
parent 47d5982ef8
commit 53e64fc3b5
1 changed files with 18 additions and 2 deletions

20
nvm.sh
View File

@ -78,6 +78,10 @@ nvm()
nvm help nvm help
return; return;
fi fi
if [ ! -d $NVM_DIR/$2 ]; then
echo "$2 version is not installed yet"
return;
fi
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$2/bin${PATH#*$NVM_DIR/*/bin} PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$2/bin${PATH#*$NVM_DIR/*/bin}
else else
@ -91,8 +95,20 @@ nvm()
nvm help nvm help
return; return;
fi fi
# TODO: put a star by the current active one if possible if [ -d $NVM_DIR/HEAD ]; then
ls "$NVM_DIR" | grep -v src | grep -v nvm.sh | grep -v README.markdown if [[ $PATH == *$NVM_DIR/HEAD/bin* ]]; then
echo "HEAD *"
else
echo "HEAD"
fi
fi
for f in $NVM_DIR/v*; do
if [[ $PATH == *$f/bin* ]]; then
echo "v${f##*v} *"
else
echo "v${f##*v}"
fi
done
;; ;;
* ) * )
nvm help nvm help