Skip to content

Commit

Permalink
Add setting to use .asdf-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yacchi committed Jun 5, 2022
1 parent a20fac7 commit cc05a03
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
13 changes: 13 additions & 0 deletions docs/manage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ legacy_version_file = no
use_release_candidates = no
always_keep_download = no
plugin_repository_last_check_duration = 60
use_asdf_plugin_configuration = no
```

### `legacy_version_file`
Expand Down Expand Up @@ -96,6 +97,18 @@ Configure the duration since the last asdf plugin repository sync to the next. C
| `0` | Sync on each trigger event |
| `never` | Never sync |

### `use_asdf_plugin_configuration`

Settings to use the configuration file `.asdf-plugin` provided by the plugin.

When using a plugin that requires this setting, set to yes.

| Options | Description |
| :--------------------------------------------------------- |:-----------------------------------------------------------------------|
| `no` <Badge type="tip" text="default" vertical="middle" /> | Do not use the .asdf-plugin configuration file provided by the plugin. |
| `yes` | Use the configuration file .asdf-plugin provided by the plugin. |


## Environment Variables

- `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location.
Expand Down
8 changes: 8 additions & 0 deletions docs/plugins/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ Add an `.asdf-plugin` file to your plugin root directory and asdf will use the s
plugin_directory =
```

To enable this, add the following to your `asdf` configuration file `$HOME/.asdfrc`:

```
use_asdf_plugin_configuration = yes
```

See the [configuration](/manage/configuration.md) reference page for more config options.

### `plugin_directory`

If you want to place plugin scripts (e.g. bin, lib) in a subdirectory, specify a path relative to the repository root.
Expand Down
18 changes: 10 additions & 8 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ get_plugin_path() {
plugins_dir="$(asdf_data_dir)/plugins"

if test -n "$1"; then
local config_file=
config_file="$plugins_dir/$1/.asdf-plugin"
if [ -f "$config_file" ]; then
local plugin_directory=
plugin_directory=$(get_asdf_config_value_from_file "$config_file" plugin_directory)
if [ -n "$plugin_directory" ] && [ -d "$plugins_dir/$1/$plugin_directory" ]; then
printf "%s\\n" "$plugins_dir/$1/$plugin_directory"
return
if [ "$(get_asdf_config_value "use_asdf_plugin_configuration")" = "yes" ]; then
local config_file=
config_file="$plugins_dir/$1/.asdf-plugin"
if [ -f "$config_file" ]; then
local plugin_directory=
plugin_directory=$(get_asdf_config_value_from_file "$config_file" plugin_directory)
if [ -n "$plugin_directory" ] && [ -d "$plugins_dir/$1/$plugin_directory" ]; then
printf "%s\\n" "$plugins_dir/$1/$plugin_directory"
return
fi
fi
fi
printf "%s\\n" "$plugins_dir/$1"
Expand Down
1 change: 1 addition & 0 deletions test/plugin_subdir.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load test_helpers

setup() {
setup_asdf_dir
echo 'use_asdf_plugin_configuration = yes' >$HOME/.asdfrc
}

teardown() {
Expand Down

0 comments on commit cc05a03

Please sign in to comment.