Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass --add to asdf install to add plugins in .tool-versions #313

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lib/commands/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ install_command() {
local plugin_name=$1
local full_version=$2

if [ "$plugin_name" = "" ] && [ "$full_version" = "" ]; then
install_local_tool_versions
if [[ ( "$plugin_name" = "" || "$plugin_name" = "--add" ) && "$full_version" = "" ]]; then
local add_plugins
if [[ $plugin_name = "--add" ]]; then
add_plugins=true
else
add_plugins=false
fi

install_local_tool_versions "$add_plugins"
elif [[ $# -eq 1 ]]; then
display_error "You must specify a name and a version to install"
exit 1
Expand All @@ -37,6 +44,8 @@ get_concurrency() {
}

install_local_tool_versions() {
local add_plugins=$1

local plugins_path
plugins_path=$(get_plugin_path)

Expand All @@ -54,6 +63,11 @@ install_local_tool_versions() {
plugin_version_and_path="$(find_version "$plugin_name" "$search_path")"

if [ -n "$plugin_version_and_path" ]; then

if [ "$add_plugins" = true ]; then
install_add_tool_plugin "$plugin_name"
fi

local plugin_version
some_tools_installed='yes'
plugin_version=$(cut -d '|' -f 1 <<< "$plugin_version_and_path")
Expand All @@ -73,6 +87,15 @@ install_local_tool_versions() {
fi
}

install_add_tool_plugin() {
local plugin_name=$1
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")

if ! [ -d "$plugin_path" ]; then
plugin_add_command "$plugin_name"
fi
}

install_tool_version() {
local plugin_name=$1
Expand Down