diff --git a/nvm.sh b/nvm.sh index 19feb7f6..d0259fcb 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2585,7 +2585,7 @@ nvm_print_versions() { -v remote_versions="$(printf '%s' "${1-}" | tr '\n' '|')" \ -v latest_alias="${NVM_LATEST_ALIAS}" \ -v node_prefix="$(nvm_node_prefix)" -v iojs_prefix="$(nvm_iojs_prefix)" \ - -v installed_versions="$(nvm_ls | tr '\n' '|')" -v current="$NVM_CURRENT" \ + -v installed_versions="$(nvm_ls | nvm_grep -v '^N/A$' | tr '\n' '|')" -v current="$NVM_CURRENT" \ -v installed_color="$INSTALLED_COLOR" -v system_color="$SYSTEM_COLOR" \ -v current_color="$CURRENT_COLOR" -v default_color="$DEFAULT_COLOR" \ -v old_lts_color="$DEFAULT_COLOR" -v has_colors="$NVM_HAS_COLORS" \ diff --git a/test/fast/Unit tests/nvm ls with nothing installed b/test/fast/Unit tests/nvm ls with nothing installed new file mode 100755 index 00000000..4619ea74 --- /dev/null +++ b/test/fast/Unit tests/nvm ls with nothing installed @@ -0,0 +1,31 @@ +#!/bin/sh + +ORIG_NVM_DIR="${NVM_DIR}" +TMP_DIR='' + +cleanup () { + case "${TMP_DIR}" in + /*) rm -rf "${TMP_DIR}" ;; + esac + NVM_DIR="${ORIG_NVM_DIR}" + export NVM_DIR +} + +die () { echo "$@" ; cleanup ; exit 1; } + +: nvm.sh +\. ../../../nvm.sh + +TMP_DIR="$(mktemp -d)" +NVM_DIR="${TMP_DIR}/nvm" +export NVM_DIR +mkdir -p "${NVM_DIR}" || die 'could not create NVM_DIR' + +nvm_has_system_node() { return 1; } +nvm_has_system_iojs() { return 1; } + +OUTPUT="$(nvm ls --no-colors --no-alias)" +EXPECTED="$(printf '%15s' 'N/A')" +[ "_${OUTPUT}" = "_${EXPECTED}" ] || die "nvm ls with nothing installed should not mark N/A as installed; got >${OUTPUT}<" + +cleanup diff --git a/test/fast/Unit tests/nvm ls-remote b/test/fast/Unit tests/nvm ls-remote index cf4a910e..a662456e 100755 --- a/test/fast/Unit tests/nvm ls-remote +++ b/test/fast/Unit tests/nvm ls-remote @@ -76,7 +76,7 @@ nvm_has_colors() { return 0; } [ $EXIT_CODE -eq 3 ] || die "nvm ls-remote lts/ARGON did not exit 3, got '${EXIT_CODE}'" EXPECTED_OUTPUT="LTS names must be lowercase - N/A *" + N/A" [ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/ARGON did not output expected error message; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<" REMOTE="${PWD}/mocks/nvm_ls_remote.txt"