diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index db8d7574..8c5d53f7 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -152,6 +152,31 @@ The default number of cores to use during compilation. 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__` +- `pre_asdf_download_` +- `{pre,post}_asdf_{install,reshim,uninstall}_` + - `$1`: full version +- `{pre,post}_asdf_plugin_{add,update,remove,reshim}` + - `$1`: plugin name +- `{pre,post}_asdf_plugin_{add,update,remove}_` + +See [Create a Plugin](../plugins/create.md) for specifics on what command hooks are ran before or after what commands. + ## 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). diff --git a/docs/plugins/create.md b/docs/plugins/create.md index afa5c92c..ae3b9701 100644 --- a/docs/plugins/create.md +++ b/docs/plugins/create.md @@ -685,14 +685,14 @@ No parameters provided. **Description** -Execute this callback script **after** asdf has downloaded the _updated_ plugin with `asdf plugin update []`. +Execute this callback script **after** asdf has downloaded the _update_ plugin with `asdf plugin update []`. See also the related command hooks: -- `pre_asdf_plugin_updated` -- `pre_asdf_plugin_updated_${plugin_name}` -- `post_asdf_plugin_updated` -- `post_asdf_plugin_updated_${plugin_name}` +- `pre_asdf_plugin_update` +- `pre_asdf_plugin_update_${plugin_name}` +- `post_asdf_plugin_update` +- `post_asdf_plugin_update_${plugin_name}` **Environment Variables available to script** diff --git a/docs/zh-hans/plugins/create.md b/docs/zh-hans/plugins/create.md index 0b4d1a28..803b3a79 100644 --- a/docs/zh-hans/plugins/create.md +++ b/docs/zh-hans/plugins/create.md @@ -150,10 +150,10 @@ bin tools veggies 其他请参考相关钩子: -- `pre_asdf_plugin_updated` -- `pre_asdf_plugin_updated_${plugin_name}` -- `post_asdf_plugin_updated` -- `post_asdf_plugin_updated_${plugin_name}` +- `pre_asdf_plugin_update` +- `pre_asdf_plugin_update_${plugin_name}` +- `post_asdf_plugin_update` +- `post_asdf_plugin_update_${plugin_name}` #### bin/pre-plugin-remove