Add nvm_is_valid_version

This commit is contained in:
Jordan Harband
2015-02-01 13:01:40 -08:00
parent 8a87133f71
commit e1b7496cf0
2 changed files with 29 additions and 0 deletions

16
nvm.sh
View File

@@ -263,6 +263,22 @@ $(nvm_ls_remote_iojs "$PATTERN")" | command grep -v "N/A" | command sed '/^$/d')
fi
}
nvm_is_valid_version() {
if nvm_validate_implicit_alias "$1" 2> /dev/null; then
return 0
fi
case "$1" in
"$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")
return 0
;;
*)
local VERSION
VERSION="$(nvm_strip_iojs_prefix "$1")"
nvm_version_greater "$VERSION"
;;
esac
}
nvm_normalize_version() {
echo "$1" | command sed -e 's/^v//' | command awk -F. '{ printf("%d%06d%06d\n", $1,$2,$3); }'
}