packages: support {$pkg}_uninstall events

Emit uninstall events independent of uninstall.fish
This commit is contained in:
fdeitylink 2021-03-02 18:11:39 -05:00 committed by Pablo Aguiar
parent b27b3b5aba
commit 0cda2c0c1f
2 changed files with 6 additions and 2 deletions

View File

@ -120,6 +120,7 @@ Inside this hook, you can access two package-related variables:
Packages can use this hook to clean up custom resources, etc.
> Note: for backwards-compatibility, uninstall hooks will also be run if they are located at `uninstall.fish` in the package root.
> Hooks may also be triggered by listening for the event `{$package}_uninstall` or `uninstall_$package`.
# Make it public

View File

@ -17,8 +17,11 @@ function omf.packages.remove -a pkg
# Run uninstall hook first.
omf.packages.run_hook $path uninstall
source $path/uninstall.fish 2> /dev/null;
and emit uninstall_$pkg
if test -f $path/uninstall.fish
source $path/uninstall.fish 2> /dev/null
end
emit uninstall_$pkg
emit {$pkg}_uninstall
if command rm -rf $path
omf.bundle.remove "package" $pkg