From b7983842aa15c1c4d27235b945226477c44f8d3a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Jan 2015 00:57:32 -0800 Subject: [PATCH] Add `nvm_add_iojs_prefix` --- nvm.sh | 6 +++++- test/fast/Unit tests/nvm_add_iojs_prefix | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 test/fast/Unit tests/nvm_add_iojs_prefix diff --git a/nvm.sh b/nvm.sh index f8aea57..73cc0b9 100644 --- a/nvm.sh +++ b/nvm.sh @@ -358,6 +358,10 @@ nvm_is_iojs_version() { [ "_$(echo "$1" | cut -c1-5)" = "_iojs-" ] } +nvm_add_iojs_prefix() { + command echo "$(nvm_iojs_prefix)-$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$1")")" +} + nvm_strip_iojs_prefix() { local NVM_IOJS_PREFIX NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" @@ -1212,7 +1216,7 @@ nvm() { "unload" ) unset -f nvm nvm_print_versions nvm_checksum \ nvm_iojs_prefix nvm_node_prefix \ - nvm_strip_iojs_prefix \ + nvm_add_iojs_prefix nvm_strip_iojs_prefix \ nvm_is_iojs_version \ nvm_ls_remote nvm_ls nvm_remote_version \ nvm_version nvm_rc_version \ diff --git a/test/fast/Unit tests/nvm_add_iojs_prefix b/test/fast/Unit tests/nvm_add_iojs_prefix new file mode 100755 index 0000000..4a8d1ee --- /dev/null +++ b/test/fast/Unit tests/nvm_add_iojs_prefix @@ -0,0 +1,9 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"' +[ "_$(nvm_add_iojs_prefix iojs-1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix iojs-1" did not return "iojs-v1"' +[ "_$(nvm_add_iojs_prefix iojs-1.2.3)" = "_iojs-v1.2.3" ] || die '"nvm_add_iojs_prefix iojs-1.2.3" did not return "iojs-v1.2.3"'