Use `nvm_num_version_groups` in `nvm_ls`

master
Jordan Harband 2014-09-16 08:36:40 -07:00
parent 4b2bc0be08
commit c992b1766c
1 changed files with 7 additions and 3 deletions

10
nvm.sh
View File

@ -247,14 +247,18 @@ nvm_ls() {
return
fi
# If it looks like an explicit version, don't do anything funny
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
if [ "~$(echo "$PATTERN" | cut -c1-1)" = "~v" ] && [ "~$(nvm_num_version_groups "$PATTERN")" = "~3" ]; then
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
VERSIONS="$PATTERN"
fi
else
PATTERN=$(nvm_format_version $PATTERN)
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
PATTERN="$PATTERN."
if [ "~$PATTERN" != "~system" ]; then
local NUM_VERSION_GROUPS
NUM_VERSION_GROUPS="$(nvm_num_version_groups "$PATTERN")"
if [ "~$NUM_VERSION_GROUPS" = "~2" ] || [ "~$NUM_VERSION_GROUPS" = "~1" ]; then
PATTERN="$(echo "$PATTERN" | sed -e 's/\.*$//g')."
fi
fi
if [ -d "$(nvm_version_dir new)" ]; then
VERSIONS=`find "$(nvm_version_dir new)/" "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \