mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
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:
parent
c1253a8dfe
commit
3c3f0e67f6
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Features
|
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)
|
* Add configurable command hooks for plugin installation and removal (#670)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -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.
|
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.
|
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`
|
||||||
* `post_asdf_plugin_add_${plugin_name}`
|
* `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.
|
This can be used to run any pre-removal actions before the plugin will be removed from asdf.
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ plugin_add_command() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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_SOURCE_URL=$source_url
|
||||||
export ASDF_PLUGIN_PATH=$plugin_path
|
export ASDF_PLUGIN_PATH=$plugin_path
|
||||||
bash "${plugin_path}/bin/plugin-add"
|
bash "${plugin_path}/bin/post-plugin-add"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -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"
|
||||||
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
|
export ASDF_PLUGIN_PATH=$plugin_path
|
||||||
bash "${plugin_path}/bin/plugin-remove"
|
bash "${plugin_path}/bin/pre-plugin-remove"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -36,6 +36,14 @@ teardown() {
|
|||||||
echo "$output" | grep "plugin does-not-exist not found in repository"
|
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)" {
|
@test "plugin_add command executes configured pre hook (generic)" {
|
||||||
install_mock_plugin_repo "dummy"
|
install_mock_plugin_repo "dummy"
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ teardown() {
|
|||||||
[ ! -f $ASDF_DIR/shims/dummy ]
|
[ ! -f $ASDF_DIR/shims/dummy ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@test "plugin_remove_command should not remove unrelated shims" {
|
@test "plugin_remove_command should not remove unrelated shims" {
|
||||||
install_dummy_plugin
|
install_dummy_plugin
|
||||||
run asdf install dummy 1.0
|
run asdf install dummy 1.0
|
||||||
@ -67,6 +66,14 @@ teardown() {
|
|||||||
[ -f $ASDF_DIR/shims/gummy ]
|
[ -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)" {
|
@test "plugin_remove_command executes configured pre hook (generic)" {
|
||||||
install_dummy_plugin
|
install_dummy_plugin
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user