mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Optimise listing all plugins
When checking if a plugin is installed (to display a flag) it is not necessary to loop through all installed plugins, since we already have a name we can check directly. Also expand test case to test this code path too.
This commit is contained in:
parent
4b857d0b7b
commit
f994b07a2c
@ -13,10 +13,7 @@ plugin_list_all_command() {
|
|||||||
source_url=$(get_plugin_source_url "$index_plugin_name")
|
source_url=$(get_plugin_source_url "$index_plugin_name")
|
||||||
installed_flag=""
|
installed_flag=""
|
||||||
|
|
||||||
for local_plugin in "$plugins_local_path"/*; do
|
[[ -d "${plugins_local_path}/${index_plugin_name}" ]] && installed_flag='*'
|
||||||
local_plugin_name=$(basename "$local_plugin")
|
|
||||||
[[ "$index_plugin_name" == "$local_plugin_name" ]] && installed_flag="*"
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "%-15s %-1s%s\\n" "$index_plugin_name" "$installed_flag" "$source_url"
|
printf "%-15s %-1s%s\\n" "$index_plugin_name" "$installed_flag" "$source_url"
|
||||||
done
|
done
|
||||||
|
1
test/fixtures/dummy_plugins_repo/plugins/dummy
vendored
Normal file
1
test/fixtures/dummy_plugins_repo/plugins/dummy
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
repository = http://example.com/dummy
|
@ -7,6 +7,7 @@ load test_helpers
|
|||||||
setup() {
|
setup() {
|
||||||
setup_asdf_dir
|
setup_asdf_dir
|
||||||
setup_repo
|
setup_repo
|
||||||
|
install_dummy_plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
@ -16,6 +17,7 @@ teardown() {
|
|||||||
@test "plugin_list_all list all plugins in the repository" {
|
@test "plugin_list_all list all plugins in the repository" {
|
||||||
run plugin_list_all_command
|
run plugin_list_all_command
|
||||||
local expected="bar http://example.com/bar
|
local expected="bar http://example.com/bar
|
||||||
|
dummy *http://example.com/dummy
|
||||||
foo http://example.com/foo"
|
foo http://example.com/foo"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user