Update `nvm_ensure_version_prefix` to support `iojs`-prefixed version strings.

master
Jordan Harband 2015-01-12 18:15:51 -08:00
parent b7983842aa
commit d28703f9e0
2 changed files with 10 additions and 1 deletions

8
nvm.sh
View File

@ -211,7 +211,13 @@ nvm_normalize_version() {
}
nvm_ensure_version_prefix() {
echo "$1" | command sed -e 's/^\([0-9]\)/v\1/g'
local NVM_VERSION
NVM_VERSION="$(nvm_strip_iojs_prefix "$1" | command sed -e 's/^\([0-9]\)/v\1/g')"
if nvm_is_iojs_version "$1"; then
echo "$(nvm_add_iojs_prefix "$NVM_VERSION")"
else
echo "$NVM_VERSION"
fi
}
nvm_format_version() {

View File

@ -7,3 +7,6 @@ die () { echo $@ ; exit 1; }
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix v1)" = "_v1" ] || die '"nvm_ensure_version_prefix v1" did not return "v1"'
[ "_$(nvm_ensure_version_prefix foo)" = "_foo" ] || die '"nvm_ensure_version_prefix foo" did not return "foo"'
[ "_$(nvm_ensure_version_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-1" did not return "iojs-v1"'
[ "_$(nvm_ensure_version_prefix iojs-v1)" = "_iojs-v1" ] || die '"nvm_ensure_version_prefix iojs-v1" did not return "iojs-v1"'