mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
20 lines
479 B
Bash
20 lines
479 B
Bash
# -*- sh -*-
|
|
|
|
latest_command() {
|
|
DEFAULT_QUERY="[0-9]"
|
|
|
|
local plugin_name=$1
|
|
local query=$2
|
|
|
|
[[ -z $query ]] && query="$DEFAULT_QUERY"
|
|
|
|
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest)
|
|
asdf list-all "$plugin_name" "$query" \
|
|
| grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\.]rc|-alpha|-beta|[-\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" \
|
|
| sed 's/^\s\+//' \
|
|
| sort --version-sort \
|
|
| tail -1
|
|
}
|
|
|
|
latest_command "$@"
|