`nvm_num_version_groups` should report 0 when given just a v or a .
parent
3d764e6833
commit
c34502ebc2
4
nvm.sh
4
nvm.sh
|
@ -333,12 +333,12 @@ nvm_format_version() {
|
||||||
nvm_num_version_groups() {
|
nvm_num_version_groups() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
|
VERSION="${VERSION#v}"
|
||||||
|
VERSION="${VERSION%.}"
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
echo "0"
|
echo "0"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
VERSION="${VERSION#v*}"
|
|
||||||
VERSION="${VERSION%\.}"
|
|
||||||
local NVM_NUM_DOTS
|
local NVM_NUM_DOTS
|
||||||
NVM_NUM_DOTS=$(echo "$VERSION" | command sed -e 's/[^\.]//g')
|
NVM_NUM_DOTS=$(echo "$VERSION" | command sed -e 's/[^\.]//g')
|
||||||
local NVM_NUM_GROUPS
|
local NVM_NUM_GROUPS
|
||||||
|
|
|
@ -5,13 +5,17 @@ die () { echo $@ ; exit 1; }
|
||||||
. ../../../nvm.sh
|
. ../../../nvm.sh
|
||||||
|
|
||||||
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
|
[ "~$(nvm_num_version_groups)" = "~0" ] || die "no args should give 0"
|
||||||
|
[ "~$(nvm_num_version_groups v)" = "~0" ] || die "just "v" should give 0"
|
||||||
|
[ "~$(nvm_num_version_groups .)" = "~0" ] || die "just "." should give 0"
|
||||||
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
|
[ "~$(nvm_num_version_groups a)" = "~1" ] || die "one letter should give 1"
|
||||||
|
|
||||||
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
|
[ "~$(nvm_num_version_groups 1)" = "~1" ] || die "1 should give 1"
|
||||||
|
[ "~$(nvm_num_version_groups 1.)" = "~1" ] || die "1. should give 1"
|
||||||
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
|
[ "~$(nvm_num_version_groups v1)" = "~1" ] || die "v1 should give 1"
|
||||||
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
|
[ "~$(nvm_num_version_groups v1.)" = "~1" ] || die "v1. should give 1"
|
||||||
|
|
||||||
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
|
[ "~$(nvm_num_version_groups 1.2)" = "~2" ] || die "1.2 should give 2"
|
||||||
|
[ "~$(nvm_num_version_groups 1.2.)" = "~2" ] || die "1.2. should give 2"
|
||||||
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
|
[ "~$(nvm_num_version_groups v1.2)" = "~2" ] || die "v1.2 should give 2"
|
||||||
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"
|
[ "~$(nvm_num_version_groups v1.2.)" = "~2" ] || die "v1.2. should give 2"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue