Print the LTS version on all versions with that info, but put the non-latest in gray.

Jordan Harband 2016-04-24 10:55:30 -07:00
parent ae07c3c345
commit 584bdd8ba3
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 31 additions and 15 deletions

24
nvm.sh
View File

@ -993,8 +993,12 @@ nvm_print_versions() {
fi
local LTS_LENGTH
local LTS_FORMAT
nvm_echo "$1" | while read -r VERSION_LINE; do
VERSION="${VERSION_LINE% *}"
nvm_echo "$1" \
| command sed '1!G;h;$!d' \
| command awk '{ if ($2 && a[$2]++) { print $1, "(LTS: " $2 ")" } else if ($2) { print $1, "(Latest LTS: " $2 ")" } else { print $0 } }' \
| command sed '1!G;h;$!d' \
| while read -r VERSION_LINE; do
VERSION="${VERSION_LINE%% *}"
LTS="${VERSION_LINE#* }"
FORMAT='%15s '
if [ "_$VERSION" = "_$NVM_CURRENT" ]; then
@ -1014,14 +1018,26 @@ nvm_print_versions() {
FORMAT='%15s *'
fi
fi
if [ "$LTS" != "$VERSION" ]; then
LTS=" (LTS: $LTS)"
if [ "${LTS}" != "${VERSION}" ]; then
case "${LTS}" in
*Latest*)
LTS="${LTS##Latest }"
LTS_LENGTH="${#LTS}"
if [ "${NVM_HAS_COLORS-}" = '1' ]; then
LTS_FORMAT="\033[1;32m%${LTS_LENGTH}s\033[0m"
else
LTS_FORMAT="%${LTS_LENGTH}s"
fi
;;
*)
LTS_LENGTH="${#LTS}"
if [ "${NVM_HAS_COLORS-}" = '1' ]; then
LTS_FORMAT="\033[0;37m%${LTS_LENGTH}s\033[0m"
else
LTS_FORMAT="%${LTS_LENGTH}s"
fi
;;
esac
command printf -- "${FORMAT}${LTS_FORMAT}\n" "$VERSION" " $LTS"
else
command printf -- "${FORMAT}\n" "$VERSION"