From f82f38be90801c9c5ef83f9336edbf614970aaff Mon Sep 17 00:00:00 2001 From: messju mohr Date: Tue, 25 Feb 2014 11:58:20 +0100 Subject: [PATCH 1/2] fixed nvm_version result when multiple versions match the given pattern --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index cf468ba..a368ac1 100644 --- a/nvm.sh +++ b/nvm.sh @@ -51,7 +51,7 @@ nvm_version() { PATTERN='current' fi - VERSION=`nvm_ls $PATTERN` + VERSION=`nvm_ls $PATTERN | tail -n1` echo "$VERSION" if [ "$VERSION" = 'N/A' ]; then From e46ee7b30bb8f2b85f12ed5d947af6fb701b422e Mon Sep 17 00:00:00 2001 From: messju mohr Date: Wed, 26 Feb 2014 08:43:12 +0100 Subject: [PATCH 2/2] added test for using the latest of two versions --- ...nstall two versions and use the latest one | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 test/slow/install two versions and use the latest one diff --git a/test/slow/install two versions and use the latest one b/test/slow/install two versions and use the latest one new file mode 100755 index 0000000..6bf23ce --- /dev/null +++ b/test/slow/install two versions and use the latest one @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e +. ../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../v0.10.25 ] && rm -R ../../v0.10.25 +[ -e ../../v0.10.26 ] && rm -R ../../v0.10.26 + +# Install from binary +nvm install 0.10.25 +nvm install 0.10.26 + +# Check +[ -d ../../v0.10.25 ] +[ -d ../../v0.10.26 ] + +# Use the first one +nvm use 0.10.25 + +# Use the latest one +nvm use 0.10 +node --version | grep v0.10.26