Ensure that `nvm run 0.12 --version` errors out sensibly when 0.12 isn't installed.
parent
e1b7496cf0
commit
0b4c1e14cf
12
nvm.sh
12
nvm.sh
|
@ -1271,7 +1271,7 @@ nvm() {
|
||||||
provided_version=$1
|
provided_version=$1
|
||||||
if [ -n "$provided_version" ]; then
|
if [ -n "$provided_version" ]; then
|
||||||
VERSION="$(nvm_version "$provided_version")"
|
VERSION="$(nvm_version "$provided_version")"
|
||||||
if [ "_$VERSION" = "_N/A" ]; then
|
if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then
|
||||||
provided_version=''
|
provided_version=''
|
||||||
if [ $has_checked_nvmrc -ne 1 ]; then
|
if [ $has_checked_nvmrc -ne 1 ]; then
|
||||||
nvm_rc_version && has_checked_nvmrc=1
|
nvm_rc_version && has_checked_nvmrc=1
|
||||||
|
@ -1290,16 +1290,20 @@ nvm() {
|
||||||
local ARGS
|
local ARGS
|
||||||
ARGS="$@"
|
ARGS="$@"
|
||||||
local OUTPUT
|
local OUTPUT
|
||||||
|
local EXIT_CODE
|
||||||
|
|
||||||
if [ "$NVM_IOJS" = true ]; then
|
if [ "_$VERSION" = "_N/A" ]; then
|
||||||
|
echo "$(nvm_ensure_version_prefix "$provided_version") is not installed yet" >&2
|
||||||
|
EXIT_CODE=1
|
||||||
|
elif [ "$NVM_IOJS" = true ]; then
|
||||||
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
||||||
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
|
OUTPUT="$(nvm use "$VERSION" >/dev/null && iojs "$ARGS")"
|
||||||
|
EXIT_CODE="$?"
|
||||||
else
|
else
|
||||||
echo "Running node $VERSION"
|
echo "Running node $VERSION"
|
||||||
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
|
OUTPUT="$(nvm use "$VERSION" >/dev/null && node "$ARGS")"
|
||||||
fi
|
|
||||||
local EXIT_CODE
|
|
||||||
EXIT_CODE="$?"
|
EXIT_CODE="$?"
|
||||||
|
fi
|
||||||
if [ -n "$OUTPUT" ]; then
|
if [ -n "$OUTPUT" ]; then
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm run 0.2 --version 2>&1)" = "v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled node version failed to error out correctly"
|
||||||
|
[ "$(nvm run iojs-0.2 --version 2>&1)" = "iojs-v0.2 is not installed yet" ] || die "\`nvm run\` with an uninstalled iojs version failed to error out correctly"
|
Loading…
Reference in New Issue