docs: Improve .asdfrc plugin hook docuentation (#1661)

This commit is contained in:
Edwin Kofler 2023-11-08 16:25:04 -08:00 committed by GitHub
parent 5737fa316e
commit 8fbf9a396b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View File

@ -152,6 +152,31 @@ The default number of cores to use during compilation.
Note: the environment variable `ASDF_CONCURRENCY` take precedence if set. Note: the environment variable `ASDF_CONCURRENCY` take precedence if set.
### Plugin Hooks
It is possible to execute custom code:
- Before or after a plugin is installed, reshimed, updated, or uninstalled
- Before or after a plugin command is executed
For example, if a plugin called `foo` is installed and provides a `bar` executable, then the following hooks can be used to execute custom code first:
```text
pre_foo_bar = echo Executing with args: $@
```
The following patterns are supported:
- `pre_<plugin_name>_<command>`
- `pre_asdf_download_<plugin_name>`
- `{pre,post}_asdf_{install,reshim,uninstall}_<plugin_name>`
- `$1`: full version
- `{pre,post}_asdf_plugin_{add,update,remove,reshim}`
- `$1`: plugin name
- `{pre,post}_asdf_plugin_{add,update,remove}_<plugin_name>`
See [Create a Plugin](../plugins/create.md) for specifics on what command hooks are ran before or after what commands.
## Environment Variables ## Environment Variables
Setting environment variables varies depending on your system and Shell. Default locations depend upon your installation location and method (Git clone, Homebrew, AUR). Setting environment variables varies depending on your system and Shell. Default locations depend upon your installation location and method (Git clone, Homebrew, AUR).

View File

@ -685,14 +685,14 @@ No parameters provided.
**Description** **Description**
Execute this callback script **after** asdf has downloaded the _updated_ plugin with `asdf plugin update <tool> [<git-ref>]`. Execute this callback script **after** asdf has downloaded the _update_ plugin with `asdf plugin update <tool> [<git-ref>]`.
See also the related command hooks: See also the related command hooks:
- `pre_asdf_plugin_updated` - `pre_asdf_plugin_update`
- `pre_asdf_plugin_updated_${plugin_name}` - `pre_asdf_plugin_update_${plugin_name}`
- `post_asdf_plugin_updated` - `post_asdf_plugin_update`
- `post_asdf_plugin_updated_${plugin_name}` - `post_asdf_plugin_update_${plugin_name}`
**Environment Variables available to script** **Environment Variables available to script**

View File

@ -150,10 +150,10 @@ bin tools veggies
其他请参考相关钩子: 其他请参考相关钩子:
- `pre_asdf_plugin_updated` - `pre_asdf_plugin_update`
- `pre_asdf_plugin_updated_${plugin_name}` - `pre_asdf_plugin_update_${plugin_name}`
- `post_asdf_plugin_updated` - `post_asdf_plugin_update`
- `post_asdf_plugin_updated_${plugin_name}` - `post_asdf_plugin_update_${plugin_name}`
#### bin/pre-plugin-remove #### bin/pre-plugin-remove