diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index 1c8338ab3..5768e3aaf 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -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` @@ -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` | 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. diff --git a/docs/plugins/create.md b/docs/plugins/create.md index 2505a1fd9..0e83118cf 100644 --- a/docs/plugins/create.md +++ b/docs/plugins/create.md @@ -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. diff --git a/lib/utils.bash b/lib/utils.bash index a74fda4b6..4a390eb46 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -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" diff --git a/test/plugin_subdir.bats b/test/plugin_subdir.bats index 300ec2a0e..467c7940c 100644 --- a/test/plugin_subdir.bats +++ b/test/plugin_subdir.bats @@ -4,6 +4,7 @@ load test_helpers setup() { setup_asdf_dir + echo 'use_asdf_plugin_configuration = yes' >$HOME/.asdfrc } teardown() {