From 0cda2c0c1f00a92a03524ade5ed8a4cbb6f938af Mon Sep 17 00:00:00 2001 From: fdeitylink <11952260+fdeitylink@users.noreply.github.com> Date: Tue, 2 Mar 2021 18:11:39 -0500 Subject: [PATCH] packages: support {$pkg}_uninstall events Emit uninstall events independent of uninstall.fish --- docs/en-US/Packages.md | 1 + pkg/omf/functions/packages/omf.packages.remove.fish | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/en-US/Packages.md b/docs/en-US/Packages.md index 9730dcd..5bd704e 100644 --- a/docs/en-US/Packages.md +++ b/docs/en-US/Packages.md @@ -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 diff --git a/pkg/omf/functions/packages/omf.packages.remove.fish b/pkg/omf/functions/packages/omf.packages.remove.fish index 0aba644..cf204aa 100644 --- a/pkg/omf/functions/packages/omf.packages.remove.fish +++ b/pkg/omf/functions/packages/omf.packages.remove.fish @@ -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