mirror of
https://github.com/jorgebucaran/fisher
synced 2024-08-17 12:31:05 +02:00
Teach uninstall handler about uninstall options.
+ Now __fisher_plugin_uninstall_handler is aware of a third argument, `option` that can be used to indicate the event handler or uninstall file abot any options available in `fisher uninstall`, namely, --force. + In addition, the uninstaller mechanism no longer receives the name of the plugin, as this information is usually already available to plugins anyway. + Finally, a path to the parent directory where the uninstall.fish file is located is given instead of the full path to the file. Again, the plugin usually knows the name of the file, `uninstall.fish`.
This commit is contained in:
parent
c56c477142
commit
b0a97ffc14
2 changed files with 15 additions and 7 deletions
|
@ -1,5 +1,8 @@
|
|||
function __fisher_plugin_uninstall_handler -a plugin file
|
||||
if source $file $plugin $file
|
||||
emit uninstall_$plugin $file
|
||||
function __fisher_plugin_uninstall_handler -a plugin file option
|
||||
set -l path (dirname $file)
|
||||
|
||||
if source $file $path "$option"
|
||||
emit uninstall_$plugin $path "$option"
|
||||
functions -e uninstall_$plugin
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
||||
set -l option "--foobar"
|
||||
|
||||
function -S setup
|
||||
mkdir -p $path
|
||||
|
@ -15,10 +16,14 @@ function -S teardown
|
|||
functions -e emit
|
||||
end
|
||||
|
||||
test "$TESTNAME - Evaluate uninstaller with plugin name and path as arguments"
|
||||
(__fisher_plugin_uninstall_handler foo $path/uninstall.fish | sed -n 1p) = "source foo $path/uninstall.fish"
|
||||
test "$TESTNAME - Evaluate uninstaller with path and \$option as arguments"
|
||||
"source $path $option" = (
|
||||
__fisher_plugin_uninstall_handler foo $path/uninstall.fish $option | sed -n 1p
|
||||
)
|
||||
end
|
||||
|
||||
test "$TESTNAME - Emit uninstall_<plugin> events with path as argument"
|
||||
(__fisher_plugin_uninstall_handler foo $path/uninstall.fish | sed -n 2p) = "emit uninstall_foo $path/uninstall.fish"
|
||||
test "$TESTNAME - Emit uninstall_<plugin> events with path and \$option as argument"
|
||||
"emit uninstall_foo $path $option" = (
|
||||
__fisher_plugin_uninstall_handler foo $path/uninstall.fish $option | sed -n 2p
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue