Skip to content
Myr

[New] `nvm ls`: add `--no-alias` to suppress alias output

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

Per https://github.com/creationix/nvm/issues/1792#issuecomment-466696504

authored by Jordan Harband · committed by Jordan Harband · parent 04fdb23 · Browse files · 4 files+59 added−1 removed
This commit

State

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

Diff stats

4 files+59 added−1 removed

  • tests:+49 added−0 removed
  • other:+10 added−1 removed

4 files+59 added−1 removed

added:test/fast/Listing versions/Running "nvm ls --no-alias" does not call into nvm_alias+34 added
1#!/bin/sh23\. ../../../nvm.sh4\. ../../common.sh56die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }78make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'9make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'10make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'11make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'1213set -e1415nvm_list_aliases() {16 echo 'sd-6'17}18# sanity check19OUTPUT="$(nvm alias)"20EXPECTED_OUTPUT='sd-6'21[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"2223nvm_ls() {24 echo v0.12.8725 echo v0.12.926 echo iojs-v0.1.227 echo iojs-v0.10.228}29OUTPUT="$(nvm ls --no-colors --no-alias)"30EXPECTED_OUTPUT=" v0.12.87 *31 v0.12.9 *32 iojs-v0.1.2 *33 iojs-v0.10.2 *"34[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
added:test/fast/Listing versions/Running "nvm ls --no-alias" with a pattern errors+15 added
1#!/bin/sh23\. ../../../nvm.sh4\. ../../common.sh56die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }78set -e910OUTPUT="$(nvm ls --no-colors --no-alias pattern 2>&1 ||:)"11EXPECTED_OUTPUT='`--no-alias` is not supported when a pattern is provided.'12EXIT_CODE="$(nvm ls --no-colors --no-alias pattern >/dev/null 2>&1 || echo $?)"13[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"1415[ "${EXIT_CODE}" = 55 ] || die "expected 55; got >${EXIT_CODE}<"
modified:.editorconfig+3 added
13 unmodified lines
1415[test/fast/Listing versions/Running "nvm ls" calls into nvm_alias]16indent_size = false1718[test/fast/Listing versions/Running "nvm ls --no-alias" does not call into nvm_alias]19indent_size = false2021[Makefile]22indent_style = tab
modified:nvm.sh+7 added-1 removed
3136 unmodified lines
3137 ;;3138 "ls" | "list")3139 local PATTERN3140 local NVM_NO_COLORS3141 local NVM_NO_ALIAS3142 while [ $# -gt 0 ]; do3143 case "${1}" in3144 --) ;;3145 --no-colors) NVM_NO_COLORS="${1}" ;;3146 --no-alias) NVM_NO_ALIAS="${1}" ;;3147 --*)3148 nvm_err "Unsupported option \"${1}\"."3149 return 553150 ;;
2 unmodified lines
3153 ;;3154 esac3155 shift3156 done3157 if [ -n "${PATTERN-}" ] && [ -n "${NVM_NO_ALIAS}" ]; then3158 nvm_err '`--no-alias` is not supported when a pattern is provided.'3159 return 553160 fi3161 local NVM_LS_OUTPUT3162 local NVM_LS_EXIT_CODE3163 NVM_LS_OUTPUT=$(nvm_ls "${PATTERN-}")3164 NVM_LS_EXIT_CODE=$?3165 NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "${NVM_LS_OUTPUT}"3160 if [ -z "${PATTERN-}" ]; then3166 if [ -z "${NVM_NO_ALIAS-}" ] && [ -z "${PATTERN-}" ]; then3167 if [ -n "${NVM_NO_COLORS-}" ]; then3168 nvm alias --no-colors3169 else3170 nvm alias
473 unmodified lines