[Fix] nvm_format_version should only return 3 version groups

This commit is contained in:
Jordan Harband
2016-02-06 22:34:49 -08:00
parent 77e0449c89
commit de64a2d95f
2 changed files with 15 additions and 6 deletions

6
nvm.sh
View File

@@ -339,10 +339,12 @@ nvm_ensure_version_prefix() {
nvm_format_version() {
local VERSION
VERSION="$(nvm_ensure_version_prefix "$1")"
if [ "_$(nvm_num_version_groups "$VERSION")" != "_3" ]; then
local NUM_GROUPS
NUM_GROUPS="$(nvm_num_version_groups "$VERSION")"
if [ $NUM_GROUPS -lt 3 ]; then
nvm_format_version "${VERSION%.}.0"
else
echo "$VERSION"
echo "$VERSION" | cut -f1-3 -d.
fi
}