From 6e02e5a54ce2314cb770de629e02a3c554bd89d2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 14 Jul 2014 11:38:26 -0700 Subject: [PATCH] If `nvm_ls` is called without a pattern, and node exists, tack on "system". --- nvm.sh | 3 +++ ...hould include \"system\" when appropriate" | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 "test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" diff --git a/nvm.sh b/nvm.sh index cc3f4d2..cdafa78 100644 --- a/nvm.sh +++ b/nvm.sh @@ -194,6 +194,9 @@ nvm_ls() { echo "N/A" return 3 fi + if [ -z "$PATTERN" ] && nvm_has_system_node; then + VERSIONS="$VERSIONS$(printf '\n%s' 'system')" + fi echo "$VERSIONS" return } diff --git "a/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" "b/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" new file mode 100755 index 0000000..9afd40a --- /dev/null +++ "b/test/fast/Listing versions/Running \"nvm ls\" should include \"system\" when appropriate" @@ -0,0 +1,21 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +mkdir -p ../../../v0.0.1 +mkdir -p ../../../v0.0.3 +mkdir -p ../../../v0.0.9 +mkdir -p ../../../v0.3.1 +mkdir -p ../../../v0.3.3 +mkdir -p ../../../v0.3.9 + +nvm_has_system_node() { return 0; } +nvm ls | grep system 2>&1 > /dev/null +[ $? -eq 0 ] || die '"nvm ls" did not contain "system" when system node is present' + +nvm_has_system_node() { return 1; } +nvm ls | grep system 2>&1 > /dev/null +[ $? -ne 0 ] || die '"nvm ls" contained "system" when system node is not present' +