Rename custom plugin-add/plugin-remove for plugins (#684)

Rename custom scripts for `plugin-add` and `plugin-remove` phases in plugins to make clear when they are executed:

`plugin-add` -> `post-plugin-add`
`plugin-remove` -> `pre-plugin-remove`
This commit is contained in:
Jochen Schalanda 2020-03-22 02:57:54 +01:00 committed by GitHub
parent c1253a8dfe
commit 3c3f0e67f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 8 deletions

View File

@ -4,7 +4,7 @@
Features
* Add support for custom `plugin-add` and `plugin-remove` in plugins (#670)
* Add support for `post-plugin-add` and `pre-plugin-remove` in plugins (#670)
* Add configurable command hooks for plugin installation and removal (#670)
```shell

View File

@ -88,7 +88,7 @@ Note: This will only apply for users who have enabled the `legacy_version_file`
This can be used to further parse the legacy file found by asdf. If `parse-legacy-file` isn't implemented, asdf will simply cat the file to determine the version. The script will be passed the file path as its first argument.
#### bin/plugin-add
#### bin/post-plugin-add
This can be used to run any post-installation actions after the plugin has been added to asdf.
@ -101,7 +101,7 @@ See also the related hooks:
* `post_asdf_plugin_add`
* `post_asdf_plugin_add_${plugin_name}`
#### bin/plugin-remove
#### bin/pre-plugin-remove
This can be used to run any pre-removal actions before the plugin will be removed from asdf.

View File

@ -37,11 +37,11 @@ plugin_add_command() {
exit 1
fi
if [ -f "${plugin_path}/bin/plugin-add" ]; then
if [ -f "${plugin_path}/bin/post-plugin-add" ]; then
(
export ASDF_PLUGIN_SOURCE_URL=$source_url
export ASDF_PLUGIN_PATH=$plugin_path
bash "${plugin_path}/bin/plugin-add"
bash "${plugin_path}/bin/post-plugin-add"
)
fi

View File

@ -10,10 +10,10 @@ plugin_remove_command() {
asdf_run_hook "pre_asdf_plugin_remove" "$plugin_name"
asdf_run_hook "pre_asdf_plugin_remove_${plugin_name}"
if [ -f "${plugin_path}/bin/plugin-remove" ]; then
if [ -f "${plugin_path}/bin/pre-plugin-remove" ]; then
(
export ASDF_PLUGIN_PATH=$plugin_path
bash "${plugin_path}/bin/plugin-remove"
bash "${plugin_path}/bin/pre-plugin-remove"
)
fi

View File

@ -36,6 +36,14 @@ teardown() {
echo "$output" | grep "plugin does-not-exist not found in repository"
}
@test "plugin_add command executes post-plugin-add script" {
install_mock_plugin_repo "dummy"
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
[ "$output" = "plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy" ]
}
@test "plugin_add command executes configured pre hook (generic)" {
install_mock_plugin_repo "dummy"

View File

@ -52,7 +52,6 @@ teardown() {
[ ! -f $ASDF_DIR/shims/dummy ]
}
@test "plugin_remove_command should not remove unrelated shims" {
install_dummy_plugin
run asdf install dummy 1.0
@ -67,6 +66,14 @@ teardown() {
[ -f $ASDF_DIR/shims/gummy ]
}
@test "plugin_remove_command executes pre-plugin-remove script" {
install_dummy_plugin
run asdf plugin-remove dummy
[ "$output" = "plugin-remove ${ASDF_DIR}/plugins/dummy" ]
}
@test "plugin_remove_command executes configured pre hook (generic)" {
install_dummy_plugin