Fix `nvm_ensure_version_installed iojs` to not print an empty string for the version.

Jordan Harband 2015-09-11 10:42:47 +09:00
parent 014a44e154
commit e3528b0d9e
2 changed files with 10 additions and 1 deletions

4
nvm.sh
View File

@ -210,7 +210,9 @@ nvm_ensure_version_installed() {
if [ $? -eq 0 ]; then
echo "N/A: version \"$PROVIDED_VERSION -> $VERSION\" is not yet installed" >&2
else
echo "N/A: version \"$(nvm_ensure_version_prefix "$PROVIDED_VERSION")\" is not yet installed" >&2
local PREFIXED_VERSION
PREFIXED_VERSION="$(nvm_ensure_version_prefix "$PROVIDED_VERSION")"
echo "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed" >&2
fi
return 1
fi

View File

@ -20,4 +20,11 @@ EXIT_CODE=$?
[ "_$OUTPUT" = "_" ] || die "expected 'nvm_ensure_version_installed 0.1' to have no output, got $OUTPUT"
[ "_$EXIT_CODE" = "_0" ] || die "expected 'nvm_ensure_version_installed 0.1' to exit with 0, got $EXIT_CODE"
# Special case for "iojs"
OUTPUT="$(nvm_ensure_version_installed iojs 2>&1)"
EXIT_CODE=$?
EXPECTED_OUTPUT='N/A: version "iojs" is not yet installed'
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "expected 'nvm_ensure_version_installed iojs' to give $EXPECTED_OUTPUT, got $OUTPUT"
[ "_$EXIT_CODE" = "_1" ] || die "expected 'nvm_ensure_version_installed iojs' to exit with 1, got $EXIT_CODE"
cleanup