diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-09-18 19:14:33 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-09-18 19:15:34 -0500 |
commit | d78f66291f0f82b6c50193b041c7a26b4ced9037 (patch) | |
tree | 972f2b9061e17f24c392b8c1e9a60ef2998280a2 /src/rebar_provider.erl | |
parent | 73ee56eace71065ff7fa15f0106c2f559a6e632b (diff) |
add support for plugins as pre and post hooks
Diffstat (limited to 'src/rebar_provider.erl')
-rw-r--r-- | src/rebar_provider.erl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rebar_provider.erl b/src/rebar_provider.erl index 3c80a80..e5d7520 100644 --- a/src/rebar_provider.erl +++ b/src/rebar_provider.erl @@ -66,7 +66,17 @@ new(ModuleName, State0) when is_atom(ModuleName) -> -spec do(Provider::t(), rebar_state:t()) -> {ok, rebar_state:t()}. do(Provider, State) -> - (Provider#provider.provider_impl):do(State). + {PreHooks, PostHooks} = rebar_state:hooks(State, Provider#provider.name), + {ok, State1} = run_hook_plugins(PreHooks, State), + {ok, State2} = (Provider#provider.provider_impl):do(State1), + run_hook_plugins(PostHooks, State2). + +run_hook_plugins(Hooks, State) -> + State1 = lists:foldl(fun(Hook, StateAcc) -> + {ok, StateAcc1} = rebar_provider:do(Hook, StateAcc), + StateAcc1 + end, State, Hooks), + {ok, State1}. %%% @doc get the name of the module that implements the provider %%% @param Provider the provider object |