Add `nvm_strip_iojs_prefix`

master
Jordan Harband 2015-01-12 18:15:25 -08:00
parent 98e0655198
commit c12104cecd
2 changed files with 21 additions and 0 deletions

11
nvm.sh
View File

@ -358,6 +358,16 @@ nvm_is_iojs_version() {
[ "_$(echo "$1" | cut -c1-5)" = "_iojs-" ]
}
nvm_strip_iojs_prefix() {
local NVM_IOJS_PREFIX
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
if [ "_$1" = "_$NVM_IOJS_PREFIX" ]; then
echo
else
echo "$1" | command sed "s/^$NVM_IOJS_PREFIX-//"
fi
}
nvm_ls() {
local PATTERN
PATTERN="$1"
@ -1202,6 +1212,7 @@ nvm() {
"unload" )
unset -f nvm nvm_print_versions nvm_checksum \
nvm_iojs_prefix nvm_node_prefix \
nvm_strip_iojs_prefix \
nvm_is_iojs_version \
nvm_ls_remote nvm_ls nvm_remote_version \
nvm_version nvm_rc_version \

View File

@ -0,0 +1,10 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
[ "_$(nvm_strip_iojs_prefix iojs)" = "_" ] || die '"nvm_strip_iojs_prefix iojs" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-)" = "_" ] || die '"nvm_strip_iojs_prefix iojs-" did not return an empty string'
[ "_$(nvm_strip_iojs_prefix iojs-foo)" = "_foo" ] || die '"nvm_strip_iojs_prefix iojs-foo" did not return "foo"'
[ "_$(nvm_strip_iojs_prefix iojsfoo)" = "_iojsfoo" ] || die '"nvm_strip_iojs_prefix iojsfoo" did not return "iojsfoo"'