Fix `nvm ls v1.0.3` so that it locates `iojs-v1.0.3`.

Also fix `nvm uninstall v1.0.3` so it won't uninstall it if it's the current version.

node versions will still take priority if there's ever a version overlap.
master
Jordan Harband 2015-01-25 12:07:29 -08:00
parent 3d3d9d3a8d
commit a6819b3018
2 changed files with 18 additions and 2 deletions

6
nvm.sh
View File

@ -469,6 +469,8 @@ nvm_ls() {
if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then if [ "_$(echo "$PATTERN" | cut -c1-1)" = "_v" ] && [ "_$(nvm_num_version_groups "$PATTERN")" = "_3" ]; then
if [ -d "$(nvm_version_path "$PATTERN")" ]; then if [ -d "$(nvm_version_path "$PATTERN")" ]; then
VERSIONS="$PATTERN" VERSIONS="$PATTERN"
elif [ -d "$(nvm_version_path "$(nvm_add_iojs_prefix "$PATTERN")")" ]; then
VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")"
fi fi
else else
case "$PATTERN" in case "$PATTERN" in
@ -1081,8 +1083,8 @@ nvm() {
VERSION="$(nvm_version "$PATTERN")" VERSION="$(nvm_version "$PATTERN")"
;; ;;
esac esac
if [ "_$PATTERN" = "_$(nvm_ls_current)" ]; then if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then
if nvm_is_iojs_version "$PATTERN"; then if nvm_is_iojs_version "$VERSION"; then
echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2 echo "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)." >&2
else else
echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2 echo "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)." >&2

View File

@ -0,0 +1,14 @@
#!/bin/sh
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
nvm deactivate 2>&1 >/dev/null || die 'deactivate failed'
nvm use 'v1.0.0' || die 'nvm use v1.0.0 failed'
OUTPUT="$(nvm current)"
EXPECTED_OUTPUT="$(nvm_version v1.0.0)"
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \
|| die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"