From 5c336a7ccb38d60f4825dcddbbe6682f581dd4ff Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Jan 2015 00:49:31 -0800 Subject: [PATCH] Make `nvm_print_versions` support iojs via `nvm_version_path`. --- nvm.sh | 14 ++++++++------ test/fast/Unit tests/nvm_version_path | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nvm.sh b/nvm.sh index 4c027ed..662b603 100644 --- a/nvm.sh +++ b/nvm.sh @@ -164,6 +164,8 @@ nvm_version_path() { if [ -z "$VERSION" ]; then echo "version is required" >&2 return 3 + elif nvm_is_iojs_version "$VERSION"; then + echo "$(nvm_version_dir iojs)/$(nvm_strip_iojs_prefix "$VERSION")" elif nvm_version_greater 0.12.0 "$VERSION"; then echo "$(nvm_version_dir old)/$VERSION" else @@ -515,14 +517,14 @@ nvm_print_versions() { local NVM_CURRENT NVM_CURRENT=$(nvm_ls_current) echo "$1" | while read VERSION; do - if [ "$VERSION" = "$NVM_CURRENT" ]; then - FORMAT='\033[0;32m-> %9s\033[0m' - elif [ -d "$(nvm_version_path "$VERSION" 2> /dev/null)" ]; then - FORMAT='\033[0;34m%12s\033[0m' + if [ "_$VERSION" = "_$NVM_CURRENT" ]; then + FORMAT='\033[0;32m-> %12s\033[0m' elif [ "$VERSION" = "system" ]; then - FORMAT='\033[0;33m%12s\033[0m' + FORMAT='\033[0;33m%15s\033[0m' + elif [ -d "$(nvm_version_path "$VERSION" 2> /dev/null)" ]; then + FORMAT='\033[0;34m%15s\033[0m' else - FORMAT='%12s' + FORMAT='%15s' fi printf "$FORMAT\n" $VERSION done diff --git a/test/fast/Unit tests/nvm_version_path b/test/fast/Unit tests/nvm_version_path index f3ca584..547ceb8 100755 --- a/test/fast/Unit tests/nvm_version_path +++ b/test/fast/Unit tests/nvm_version_path @@ -8,4 +8,5 @@ die () { echo $@ ; exit 1; } [ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out' [ "$(nvm_version_path v0.11.0)" = "$NVM_DIR/v0.11.0" ] || die 'old version has the wrong path' [ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/node/v0.12.0" ] || die 'new version has the wrong path' +[ "$(nvm_version_path iojs-v0.12.0)" = "$NVM_DIR/versions/io.js/v0.12.0" ] || die 'iojs version has the wrong path'