summaryrefslogtreecommitdiff
path: root/src/rebar_core.erl
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2011-06-06 08:02:50 -0700
committerDave Smith <dizzyd@dizzyd.com>2011-06-06 08:02:50 -0700
commitab116276b73dafbd14cbe9c0e5e8a29501a3fd22 (patch)
treedfdda82a5c2b567e646e473d366d84abee25bb1b /src/rebar_core.erl
parent3440d8183bbf9c5de9bf6962a57afee0b2850431 (diff)
parentc07b0954ebac6913dba82b3e81bca7f7a39d8293 (diff)
Merge pull request #80 from hyperthunk/plugin-hooks
Allow plugins to run before/after a rebar command.
Diffstat (limited to 'src/rebar_core.erl')
-rw-r--r--src/rebar_core.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index f17ed0b..cb2c508 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -148,9 +148,17 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
%% in preprocess.
{ok, PluginModules} = plugin_modules(Config),
+ %% Execute any before_command plugins on this directory
+ execute_pre(Command, PluginModules,
+ Config, ModuleSetFile),
+
%% Execute the current command on this directory
execute(Command, Modules ++ PluginModules,
- Config, ModuleSetFile)
+ Config, ModuleSetFile),
+
+ %% Execute any after_command plugins on this directory
+ execute_post(Command, PluginModules,
+ Config, ModuleSetFile)
end,
%% Mark the current directory as processed
@@ -215,6 +223,17 @@ is_dir_type(rel_dir, Dir) ->
is_dir_type(_, _) ->
false.
+execute_pre(Command, Modules, Config, ModuleFile) ->
+ execute_plugin_hook("pre_", Command, Modules,
+ Config, ModuleFile).
+
+execute_post(Command, Modules, Config, ModuleFile) ->
+ execute_plugin_hook("post_", Command, Modules,
+ Config, ModuleFile).
+
+execute_plugin_hook(Hook, Command, Modules, Config, ModuleFile) ->
+ HookFunction = list_to_atom(Hook ++ atom_to_list(Command)),
+ execute(HookFunction, Modules, Config, ModuleFile).
%%
%% Execute a command across all applicable modules