Skip to content
Myr

Prevent attempts to `nvm use` a circular reference.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent 9b91734 · Browse files · 2 files+25 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−0 removed

  • tests:+22 added−0 removed
  • other:+3 added−0 removed

2 files+25 added−0 removed

added:test/fast/Running "nvm use foo" where "foo" is circular aborts+22 added
1#!/bin/sh23die () { echo $@ ; cleanup ; exit 1; }45cleanup() {6 rm -rf ../../alias/foo7}89. ../../nvm.sh1011echo 'foo' > ../../alias/foo1213OUTPUT="$(nvm use foo 2>&1)"14EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'15[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \16 || die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"1718EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"19[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"2021cleanup;22
modified:nvm.sh+3 added
819 unmodified lines
820 else821 echo "System version of node not found." >&2822 return 127823 fi824 elif [ "_$VERSION" = "_∞" ]; then825 echo "The alias \"$2\" leads to an infinite loop. Aborting." >&2826 return 8827 fi828829 local NVM_VERSION_DIR830 NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
228 unmodified lines