mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
feat: mark current resolved versions in asdf list
output (#762)
Co-authored-by: botp <botpena@example.com> Co-authored-by: James Hegedus <jthegedus@hey.com>
This commit is contained in:
parent
b94ac1d6c8
commit
5ea67953be
@ -27,6 +27,9 @@ display_installed_versions() {
|
||||
local plugin_name=$1
|
||||
local query=$2
|
||||
local versions
|
||||
local current_version
|
||||
local flag
|
||||
|
||||
versions=$(list_installed_versions "$plugin_name")
|
||||
|
||||
if [[ $query ]]; then
|
||||
@ -39,8 +42,14 @@ display_installed_versions() {
|
||||
fi
|
||||
|
||||
if [ -n "${versions}" ]; then
|
||||
current_version=$(cut -d '|' -f 1 <<<"$(find_versions "$plugin_name" "$(pwd)")")
|
||||
|
||||
for version in $versions; do
|
||||
printf " %s\\n" "$version"
|
||||
flag=" "
|
||||
if [[ "$version" == "$current_version" ]]; then
|
||||
flag=" *"
|
||||
fi
|
||||
printf "%s%s\\n" "$flag" "$version"
|
||||
done
|
||||
else
|
||||
display_error ' No versions installed'
|
||||
|
@ -6,6 +6,9 @@ setup() {
|
||||
setup_asdf_dir
|
||||
install_dummy_plugin
|
||||
install_dummy_broken_plugin
|
||||
|
||||
PROJECT_DIR=$HOME/project
|
||||
mkdir $PROJECT_DIR
|
||||
}
|
||||
|
||||
teardown() {
|
||||
@ -21,6 +24,18 @@ teardown() {
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "list_command should list plugins with installed versions and any selected versions marked with asterisk" {
|
||||
cd $PROJECT_DIR
|
||||
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf install dummy 1.1.0
|
||||
|
||||
run asdf list
|
||||
[[ "$output" == *"$(echo -e "dummy\n 1.0.0\n *1.1.0")"* ]]
|
||||
[[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "list_command should continue listing even when no version is installed for any of the plugins" {
|
||||
run install_mock_plugin "dummy"
|
||||
run install_mock_plugin "mummy"
|
||||
|
Loading…
Reference in New Issue
Block a user