diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2011-06-06 08:02:50 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2011-06-06 08:02:50 -0700 |
commit | ab116276b73dafbd14cbe9c0e5e8a29501a3fd22 (patch) | |
tree | dfdda82a5c2b567e646e473d366d84abee25bb1b | |
parent | 3440d8183bbf9c5de9bf6962a57afee0b2850431 (diff) | |
parent | c07b0954ebac6913dba82b3e81bca7f7a39d8293 (diff) |
Merge pull request #80 from hyperthunk/plugin-hooks
Allow plugins to run before/after a rebar command.
-rw-r--r-- | src/rebar_core.erl | 21 |
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 |