From 673cda56c4ab4fdf6804091a496accaa0abc0624 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 4 May 2014 12:03:26 -0700 Subject: [PATCH] Adding a test for `nvm install invalid` behavior, and correcting the message. From https://github.com/creationix/nvm/commit/f00d688c87873a9e3cffc1dbf54f63e0edd6e69b#commitcomment-6205164 --- nvm.sh | 2 +- ...g \"nvm install\" with an invalid version fails nicely" | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 "test/fast/Running \"nvm install\" with an invalid version fails nicely" diff --git a/nvm.sh b/nvm.sh index 88cd471..5ac6cb7 100644 --- a/nvm.sh +++ b/nvm.sh @@ -309,7 +309,7 @@ nvm() { [ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return if [ "$VERSION" = "N/A" ]; then - echo "Version '$VERSION' not found - try \`nvm ls-remote\` to browse available versions." + echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." return 3 fi diff --git "a/test/fast/Running \"nvm install\" with an invalid version fails nicely" "b/test/fast/Running \"nvm install\" with an invalid version fails nicely" new file mode 100755 index 0000000..2f556e9 --- /dev/null +++ "b/test/fast/Running \"nvm install\" with an invalid version fails nicely" @@ -0,0 +1,7 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../nvm.sh +[ "$(nvm install invalid.invalid)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" +