PKz[@8Running "nvm ls --no-alias" does not call into nvm_aliasnuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; } make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made' make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made' make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made' make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made' set -e nvm_list_aliases() { echo 'sd-6' } # sanity check OUTPUT="$(nvm alias)" EXPECTED_OUTPUT='sd-6' [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" nvm_ls() { echo v0.12.87 echo v0.12.9 echo iojs-v0.1.2 echo iojs-v0.10.2 } OUTPUT="$(nvm ls --no-colors --no-alias)" EXPECTED_OUTPUT=" v0.12.87 * v0.12.9 * iojs-v0.1.2 * iojs-v0.10.2 *" [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" PKz[ o41Running "nvm ls --no-alias" with a pattern errorsnuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; } set -e OUTPUT="$(nvm ls --no-colors --no-alias pattern 2>&1 ||:)" EXPECTED_OUTPUT='`--no-alias` is not supported when a pattern is provided.' EXIT_CODE="$(nvm ls --no-colors --no-alias pattern >/dev/null 2>&1 || echo $?)" [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" [ "${EXIT_CODE}" = 55 ] || die "expected 55; got >${EXIT_CODE}<" PKz[T9Running "nvm ls 0.0.2" should display only version 0.0.2.nuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.0.2 make_fake_node v0.0.20 die () { echo "$@" ; exit 1; } # The result should contain only the appropriate version numbers. nvm ls 0.0.2 | grep 'v0.0.2' > /dev/null if [ $? -eq 0 ]; then echo '"nvm ls 0.0.2" contained v0.0.2' fi nvm ls 0.0.2 | grep 'v0.0.20' > /dev/null if [ $? -eq 0 ]; then die '"nvm ls 0.0.2" contained v0.0.20' fi PKz[[_]]8Running "nvm ls 0.2" should display only 0.2.x versions.nuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.1.3 make_fake_node v0.2.3 make_fake_node v0.20.3 die () { echo "$@" ; exit 1; } # The result should contain only the appropriate version numbers. nvm ls 0.1 | grep 'v0.2.3' > /dev/null if [ $? -eq 0 ]; then echo '"nvm ls 0.1" contained v0.2.3' fi nvm ls 0.1 | grep 'v0.20.3' > /dev/null if [ $? -eq 0 ]; then die '"nvm ls 0.1" contained v0.20.3' fi nvm ls 0.1 | grep 'v0.1.3' > /dev/null if [ $? -ne 0 ]; then die '"nvm ls 0.1" did not contain v0.1.3' fi nvm ls 0.2 | grep 'v0.2.3' > /dev/null if [ $? -ne 0 ]; then die '"nvm ls 0.2" did not contain v0.2.3' fi nvm ls 0.2 | grep 'v0.20.3' > /dev/null if [ $? -eq 0 ]; then die '"nvm ls 0.2" contained v0.20.3' fi nvm ls 0.2 | grep 'v0.2.3' > /dev/null if [ $? -ne 0 ]; then die '"nvm ls 0.2" did not contain v0.2.3' fi PKz[kOwJIIERunning "nvm ls foo" should return a nonzero exit code when not foundnuȯ#!/bin/sh \. ../../../nvm.sh nvm ls nonexistent_version [ "$?" = "3" ] PKz[Zh88$Running "nvm ls io" should return NAnuȯ#!/bin/sh \. ../../../nvm.sh nvm ls io [ "$?" = "3" ] PKz[;;GRunning "nvm ls node_" should return a nonzero exit code when not foundnuȯ#!/bin/sh \. ../../../nvm.sh nvm ls node_ [ "$?" = "3" ] PKz[Y~ZRunning "nvm ls stable" and "nvm ls unstable" should return the appropriate implicit aliasnuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh die () { echo "$@" ; exit 1; } make_fake_node v0.2.3 make_fake_node v0.3.3 EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)" STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")" EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)" UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")" nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \ || die "expected 'nvm ls stable' to give $STABLE_VERSION, got $(nvm ls stable)" nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \ || die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)" make_fake_node v0.1.4 nvm alias stable 0.1 nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \ || die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.4" nvm ls stable | \grep v0.1.4 >/dev/null \ || die "'nvm ls stable' did not contain v0.1.4" PKz[..@Running "nvm ls system" should include "system" when appropriatenuȯ#!/bin/sh die () { echo "$@" ; exit 1; } \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.0.1 make_fake_node v0.0.3 make_fake_node v0.0.9 make_fake_node v0.3.1 make_fake_node v0.3.3 make_fake_node v0.3.9 nvm_has_system_node() { return 0; } nvm ls system | grep system 2>&1 > /dev/null [ $? -eq 0 ] || die '"nvm ls system" did not contain "system" when system node is present' nvm_has_system_node() { return 1; } nvm ls system | grep system 2>&1 > /dev/null [ $? -ne 0 ] || die '"nvm ls system" contained "system" when system node is not present' PKz[Szz%Running "nvm ls" calls into nvm_aliasnuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; } make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made' make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made' make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made' make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made' set -e nvm_list_aliases() { echo 'sd-6' } # sanity check OUTPUT="$(nvm alias)" EXPECTED_OUTPUT='sd-6' [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" nvm_ls() { echo v0.12.87 echo v0.12.9 echo iojs-v0.1.2 echo iojs-v0.10.2 } OUTPUT="$(nvm ls --no-colors)" EXPECTED_OUTPUT=" v0.12.87 * v0.12.9 * iojs-v0.1.2 * iojs-v0.10.2 * sd-6" [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" PKz[7Running "nvm ls" should display all installed versions.nuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh die () { echo "$@" ; exit 1; } make_fake_node v0.0.1 make_fake_node v0.0.3 make_fake_node v0.0.9 make_fake_node v0.3.1 make_fake_node v0.3.3 make_fake_node v0.3.9 make_fake_node v0.12.87 make_fake_node v0.12.9 make_fake_iojs v0.1.2 make_fake_iojs v0.10.2 # The result should contain the version numbers. nvm ls | grep v0.0.1 >/dev/null || die "v0.0.1 not found in: $(nvm ls)" nvm ls | grep v0.0.3 >/dev/null || die "v0.0.3 not found in: $(nvm ls)" nvm ls | grep v0.0.9 >/dev/null || die "v0.0.9 not found in: $(nvm ls)" nvm ls | grep v0.3.1 >/dev/null || die "v0.3.1 not found in: $(nvm ls)" nvm ls | grep v0.3.3 >/dev/null || die "v0.3.3 not found in: $(nvm ls)" nvm ls | grep v0.3.9 >/dev/null || die "v0.3.9 not found in: $(nvm ls)" nvm ls | grep v0.12.87 >/dev/null || die "v0.12.87 not found in: $(nvm ls)" nvm ls | grep iojs-v0.1.2 >/dev/null || die "iojs-v0.1.2 not found in: $(nvm ls)" OUTPUT="$(nvm_ls)" EXPECTED_OUTPUT="v0.0.1 v0.0.3 v0.0.9 iojs-v0.1.2 v0.3.1 v0.3.3 v0.3.9 iojs-v0.10.2 v0.12.9 v0.12.87" if nvm_has_system_node || nvm_has_system_iojs; then EXPECTED_OUTPUT="${EXPECTED_OUTPUT} system" fi [ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<" PKz[0)Running "nvm ls" should filter out ".nvm"nuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.1.3 make_fake_node v0.2.3 [ -z `nvm ls | grep '^ *\.'` ] # The result should contain only the appropriate version numbers. PKz[8-Running "nvm ls" should filter out "versions"nuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.1.3 make_fake_node v0.2.3 [ -z "$(nvm ls | \grep 'versions')" ] # The result should contain only the appropriate version numbers. PKz[9x9Running "nvm ls" should include "system" when appropriatenuȯ#!/bin/sh die () { echo "$@" ; exit 1; } \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.0.1 make_fake_node v0.0.3 make_fake_node v0.0.9 make_fake_node v0.3.1 make_fake_node v0.3.3 make_fake_node v0.3.9 nvm_has_system_node() { return 0; } nvm ls | grep system 2>&1 > /dev/null [ $? -eq 0 ] || die '"nvm ls" did not contain "system" when system node is present' nvm_has_system_node() { return 1; } nvm ls | grep system 2>&1 > /dev/null [ $? -ne 0 ] || die '"nvm ls" contained "system" when system node is not present' PKz[#z@@ARunning "nvm ls" should list versions in the "versions" directorynuȯ#!/bin/sh die () { echo "$@" ; exit 1; } \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.12.1 make_fake_node v0.1.3 nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory' nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory' PKz[s*TRunning "nvm ls" with node-like versioning vx.x.x should only list a matched versionnuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.1.2 nvm ls v0.1 | grep v0.1.2 && nvm ls v0.1.2 | grep v0.1.2 && nvm ls v0.1. | grep v0.1.2 && nvm ls v0.1.1 | grep N/A PKz[Tēnn.Running "nvm ls" with nounset should not fail.nuȯ#!/bin/sh die () { echo "$@" ; exit 1; } \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.12.34 || die 'fake v0.12.34 could not be made' # Enable no unset variable set -u # Try an alias that does not exist output=$(nvm ls 99 2>&1 1>/dev/null || true) test -z "${output}" || die "1: expected empty; got >${output}" # Try a version that does not exist output=$(nvm ls 0.12.00 2>&1 1>/dev/null || true) test -z "${output}" || die "2: expected empty; got >${output}" # Try a version that does exist output=$(nvm ls 0.12.34 2>&1 1>/dev/null || true) test -z "${output}" || die "3: expected empty; got >${output}" PKz[[))(Using a nonstandard IFS should not breaknuȯ#!/bin/sh \. ../../../nvm.sh \. ../../common.sh make_fake_node v0.0.1 make_fake_node v0.0.3 make_fake_node v0.0.9 make_fake_node v0.3.1 make_fake_node v0.3.3 make_fake_node v0.3.9 make_fake_node v0.12.87 make_fake_node v0.12.9 make_fake_iojs v0.1.2 make_fake_iojs v0.10.2 set -e IFS='' nvm ls PKz[3teardownnuȯrm -rf ../../../v0.0.1 rm -rf ../../../v0.0.2 rm -rf ../../../v0.0.3 rm -rf ../../../v0.0.9 rm -rf ../../../v0.0.20 rm -rf ../../../v0.1.2 rm -rf ../../../v0.1.3 rm -rf ../../../v0.1.4 rm -rf ../../../v0.2.3 rm -rf ../../../v0.3.1 rm -rf ../../../v0.3.3 rm -rf ../../../v0.3.9 rm -rf ../../../v0.20.3 rm -rf ../../../versions rm -f ../../../alias/stable rm -f ../../../alias/unstable PKz[@8Running "nvm ls --no-alias" does not call into nvm_aliasnuȯPKz[ o41Running "nvm ls --no-alias" with a pattern errorsnuȯPKz[T9=Running "nvm ls 0.0.2" should display only version 0.0.2.nuȯPKz[[_]]8ARunning "nvm ls 0.2" should display only 0.2.x versions.nuȯPKz[kOwJIIE Running "nvm ls foo" should return a nonzero exit code when not foundnuȯPKz[Zh88$ Running "nvm ls io" should return NAnuȯPKz[;;GP Running "nvm ls node_" should return a nonzero exit code when not foundnuȯPKz[Y~ZRunning "nvm ls stable" and "nvm ls unstable" should return the appropriate implicit aliasnuȯPKz[..@Running "nvm ls system" should include "system" when appropriatenuȯPKz[Szz%Running "nvm ls" calls into nvm_aliasnuȯPKz[7Running "nvm ls" should display all installed versions.nuȯPKz[0)Running "nvm ls" should filter out ".nvm"nuȯPKz[8-Running "nvm ls" should filter out "versions"nuȯPKz[9x9 Running "nvm ls" should include "system" when appropriatenuȯPKz[#z@@A"Running "nvm ls" should list versions in the "versions" directorynuȯPKz[s*TA$Running "nvm ls" with node-like versioning vx.x.x should only list a matched versionnuȯPKz[Tēnn.%Running "nvm ls" with nounset should not fail.nuȯPKz[[))(M(Using a nonstandard IFS should not breaknuȯPKz[3)teardownnuȯPK+