summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-09-04 22:37:37 -0500
committerTristan Sloughter <t@crashfast.com>2015-09-04 22:37:37 -0500
commit8c7bed454d7423cd4ba163bd9aea56d892257885 (patch)
tree37df4512f3b1e3de405ca4038165c0c23201eaac
parenta311961e8b6c1634bc3beee9854f5b2d4f72393d (diff)
add current_app attribute for setting before calling hooks
-rw-r--r--src/rebar3.erl1
-rw-r--r--src/rebar_hooks.erl5
-rw-r--r--src/rebar_state.erl12
3 files changed, 13 insertions, 5 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 52b4094..5233f8e 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -225,7 +225,6 @@ global_option_spec_list() ->
%% {Name, ShortOpt, LongOpt, ArgSpec, HelpMsg}
{help, $h, "help", undefined, "Print this help."},
{version, $v, "version", undefined, "Show version information."},
- %{config, $C, "config", string, "Rebar config file to use."},
{task, undefined, undefined, string, "Task to run."}
].
diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl
index 6db3c77..f17e815 100644
--- a/src/rebar_hooks.erl
+++ b/src/rebar_hooks.erl
@@ -11,8 +11,9 @@
atom() | {atom(), atom()} | string(),
[providers:t()], rebar_app_info:t(), rebar_state:t()) -> ok.
run_all_hooks(Dir, Type, Command, Providers, AppInfo, State) ->
- run_provider_hooks(Dir, Type, Command, Providers, rebar_app_info:opts(AppInfo), State),
- run_hooks(Dir, Type, Command, rebar_app_info:opts(AppInfo), State).
+ State1 = rebar_state:current_app(State, AppInfo),
+ run_provider_hooks(Dir, Type, Command, Providers, rebar_app_info:opts(AppInfo), State1),
+ run_hooks(Dir, Type, Command, rebar_app_info:opts(AppInfo), State1).
run_all_hooks(Dir, Type, Command, Providers, State) ->
run_provider_hooks(Dir, Type, Command, Providers, rebar_state:opts(State), State),
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 2a5aa01..176a80b 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -27,6 +27,7 @@
dir/1, dir/2,
create_logic_providers/2,
+ current_app/1, current_app/2,
project_apps/1, project_apps/2,
deps_to_build/1, deps_to_build/2,
all_plugin_deps/1, all_plugin_deps/2, update_all_plugin_deps/2,
@@ -49,12 +50,13 @@
escript_path :: undefined | file:filename_all(),
lock = [],
- current_profiles = [default] :: [atom()],
- namespace = default :: atom(),
+ current_profiles = [default] :: [atom()],
+ namespace = default :: atom(),
command_args = [],
command_parsed_args = {[], []},
+ current_app :: rebar_app_info:t(),
project_apps = [] :: [rebar_app_info:t()],
deps_to_build = [] :: [rebar_app_info:t()],
all_plugin_deps = [] :: [rebar_app_info:t()],
@@ -302,6 +304,12 @@ deps_names(State) ->
Deps = rebar_state:get(State, deps, []),
deps_names(Deps).
+current_app(#state_t{current_app=CurrentApp}) ->
+ CurrentApp.
+
+current_app(State=#state_t{}, CurrentApp) ->
+ State#state_t{current_app=CurrentApp}.
+
project_apps(#state_t{project_apps=Apps}) ->
Apps.