summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2016-05-16 13:33:39 -0500
committerTristan Sloughter <t@crashfast.com>2016-05-16 13:33:39 -0500
commit9f5a30f3d792bb2aa960d22eadb9219e28f992f2 (patch)
tree5549433721c38442279fe0918e7aaf078f094016
parentb8c81edb1e9e008e440e022ba11123a7169b4306 (diff)
parent15dda967b72b5f0a766f9d134861e87283ccf35d (diff)
Merge pull request #1194 from tsloughter/provider_hook_paths
don't needlessly update the code path twice if no hooks to run
-rw-r--r--src/rebar_hooks.erl28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl
index 3af17ca..d6a0e2b 100644
--- a/src/rebar_hooks.erl
+++ b/src/rebar_hooks.erl
@@ -38,18 +38,22 @@ run_provider_hooks(Dir, Type, Command, Providers, Opts, State) ->
run_provider_hooks_(_Dir, _Type, _Command, _Providers, [], State) ->
State;
run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) ->
- PluginDepsPaths = rebar_state:code_paths(State, all_plugin_deps),
- code:add_pathsa(PluginDepsPaths),
- Providers1 = rebar_state:providers(State),
- State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1),
- HookProviders = proplists:get_all_values(Command, TypeHooks),
- case rebar_core:do(HookProviders, State1) of
- {error, ProviderName} ->
- ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []),
- throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName}));
- {ok, State2} ->
- rebar_utils:remove_from_code_path(PluginDepsPaths),
- State2
+ case proplists:get_all_values(Command, TypeHooks) of
+ [] ->
+ State;
+ HookProviders ->
+ PluginDepsPaths = lists:usort(rebar_state:code_paths(State, all_plugin_deps)),
+ code:add_pathsa(PluginDepsPaths),
+ Providers1 = rebar_state:providers(State),
+ State1 = rebar_state:providers(rebar_state:dir(State, Dir), Providers++Providers1),
+ case rebar_core:do(HookProviders, State1) of
+ {error, ProviderName} ->
+ ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []),
+ throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName}));
+ {ok, State2} ->
+ rebar_utils:remove_from_code_path(PluginDepsPaths),
+ State2
+ end
end.
format_error({bad_provider, Type, Command, {Name, Namespace}}) ->