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:
Jorge Bucaran 2016-02-17 13:53:24 +09:00
parent 998fa92ebd
commit fbf973e9e4
2 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,8 @@
function __fisher_plugin_uninstall_handler -a plugin file function __fisher_plugin_uninstall_handler -a plugin file option
if source $file $plugin $file set -l path (dirname $file)
emit uninstall_$plugin $file
if source $file $path "$option"
emit uninstall_$plugin $path "$option"
functions -e uninstall_$plugin
end end
end end

View File

@ -1,4 +1,5 @@
set -l path $DIRNAME/.t-$TESTNAME-(random) set -l path $DIRNAME/.t-$TESTNAME-(random)
set -l option "--foobar"
function -S setup function -S setup
mkdir -p $path mkdir -p $path
@ -15,10 +16,14 @@ function -S teardown
functions -e emit functions -e emit
end end
test "$TESTNAME - Evaluate uninstaller with plugin name and path as arguments" test "$TESTNAME - Evaluate uninstaller with path and \$option as arguments"
(__fisher_plugin_uninstall_handler foo $path/uninstall.fish | sed -n 1p) = "source foo $path/uninstall.fish" "source $path $option" = (
__fisher_plugin_uninstall_handler foo $path/uninstall.fish $option | sed -n 1p
)
end end
test "$TESTNAME - Emit uninstall_<plugin> events with path as argument" test "$TESTNAME - Emit uninstall_<plugin> events with path and \$option as argument"
(__fisher_plugin_uninstall_handler foo $path/uninstall.fish | sed -n 2p) = "emit uninstall_foo $path/uninstall.fish" "emit uninstall_foo $path $option" = (
__fisher_plugin_uninstall_handler foo $path/uninstall.fish $option | sed -n 2p
)
end end