Add hooks for plugin uninstall

This commit is contained in:
Victor Hugo Borja 2019-01-19 13:48:21 -06:00
parent dcc3727cab
commit 9420ca1aec
3 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,9 @@ Features
pre_foo_bar = echo about to execute command bar from foo with args: ${@}
post_foo_bar = echo just executed command bar from foo with args: ${@}
pre_asdf_uninstall_foo = echo will remove foo version ${1}
post_asdf_uninstall_foo = echo removed foo version ${1}
```
* New shim version meta-data allows shims to not depend on a particular plugin
nor on its relative executable path (#431)

View File

@ -23,6 +23,7 @@ uninstall_command() {
exit 1
fi
asdf_run_hook "pre_asdf_uninstall_${plugin_name}" "$full_version"
remove_shims_for_version "$plugin_name" "$full_version"
if [ -f "${plugin_path}/bin/uninstall" ]; then
@ -35,4 +36,6 @@ uninstall_command() {
else
rm -rf "$install_path"
fi
asdf_run_hook "post_asdf_uninstall_${plugin_name}" "$full_version"
}

View File

@ -86,3 +86,24 @@ teardown() {
run uninstall_command dummy 1.0
[ -f $ASDF_DIR/shims/gummy ]
}
@test "uninstall command executes configured pre hook" {
cat > $HOME/.asdfrc <<-'EOM'
pre_asdf_uninstall_dummy = echo will uninstall dummy $1
EOM
run install_command dummy 1.0
run uninstall_command dummy 1.0
[ "$output" == "will uninstall dummy 1.0" ]
}
@test "uninstall command executes configured post hook" {
cat > $HOME/.asdfrc <<-'EOM'
post_asdf_uninstall_dummy = echo removed dummy $1
EOM
run install_command dummy 1.0
run uninstall_command dummy 1.0
echo $output
[ "$output" == "removed dummy 1.0" ]
}