From bc98a4820ed17ebcfcf98440f6d2cb63826bd1fb Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Sat, 12 Mar 2011 10:32:58 +0100 Subject: Simplify hook changes to rebar_core --- src/rebar_core.erl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 3f8068a..42f301f 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -305,19 +305,13 @@ run_modules([Module | Rest], Command, Config, File) -> end. apply_hooks(Mode, Config, Command) -> - case rebar_config:get_local(Config, Mode, []) of - [] -> - skip; - Hooks when is_list(Hooks) -> - lists:foreach(fun apply_hook/1, - [{Command, Hook} || Hook <- Hooks]) - end. + Hooks = rebar_config:get_local(Config, Mode, []), + lists:foreach(fun apply_hook/1, + [Hook || Hook <- Hooks, element(1, Hook) =:= Command]). -apply_hook({Command, {Command, Hook}}) -> +apply_hook({Command, Hook}) -> Msg = lists:flatten(io_lib:format("Command [~p] failed!~n", [Command])), - rebar_utils:sh(Hook, [{abort_on_error, Msg}]); -apply_hook({Command, {HookCmd, _}}) when Command =/= HookCmd -> - skip. + rebar_utils:sh(Hook, [{abort_on_error, Msg}]). acc_modules(Modules, Command, Config, File) -> acc_modules(select_modules(Modules, Command, []), -- cgit v1.1