Skip to content

Commit d1f09c3

Browse files
Change asdf install to loop through available plugins
1 parent ac2eede commit d1f09c3

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

‎lib/commands/install.sh‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,35 @@ get_concurrency() {
3737
}
3838

3939
install_local_tool_versions() {
40-
local asdf_versions_path
41-
asdf_versions_path=$(find_tool_versions)
42-
if [ -f "${asdf_versions_path}" ]; then
43-
while IFS= read -r tool_line; do
44-
IFS=' ' read -r -a tool_info <<< "$tool_line"
45-
local tool_name
46-
tool_name=$(echo "${tool_info[0]}" | xargs)
47-
local tool_version
48-
tool_version=$(echo "${tool_info[1]}" | xargs)
49-
50-
if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then
51-
install_tool_version "$tool_name" "$tool_version"
40+
local plugins_path
41+
plugins_path=$(get_plugin_path)
42+
43+
local search_path
44+
search_path=$(pwd)
45+
46+
local some_tools_installed
47+
48+
if ls "$plugins_path" &> /dev/null; then
49+
for plugin_path in "$plugins_path"/* ; do
50+
local plugin_name
51+
plugin_name=$(basename "$plugin_path")
52+
53+
local plugin_version_and_path
54+
plugin_version_and_path="$(find_version "$plugin_name" "$search_path")"
55+
56+
if [ -n "$plugin_version_and_path" ]; then
57+
local plugin_version
58+
plugin_version=$(cut -d '|' -f 1 <<< "$plugin_version_and_path")
59+
install_tool_version "$plugin_name" "$plugin_version"
60+
some_tools_installed='yes'
5261
fi
53-
done <<<"$(strip_tool_version_comments "$asdf_versions_path")"
62+
done
5463
else
64+
echo "Install plugins first to be able to install tools"
65+
exit 1
66+
fi
67+
68+
if [ -z "$some_tools_installed" ]; then
5569
echo "Either specify a tool & version in the command"
5670
echo "OR add .tool-versions file in this directory"
5771
echo "or in a parent directory"

0 commit comments

Comments
 (0)