summaryrefslogtreecommitdiff
path: root/src/rebar_prv_as.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-10-05 01:23:49 +0000
committerFred Hebert <mononcqc@ferd.ca>2015-10-05 01:23:49 +0000
commitc4ec25cfaa9df659214684367097f4c1c3d8d08d (patch)
treecdc7e0156f775d31be1e806113f356e6bfb7f993 /src/rebar_prv_as.erl
parent2b228fafce32b7b523c1649d86926ae18ceb1346 (diff)
parent625f76f4cd795162deaacd3a372ea979136b42c3 (diff)
Merge branch 'no_profile' of https://github.com/tsloughter/rebar3 into tsloughter-no_profile
Diffstat (limited to 'src/rebar_prv_as.erl')
-rw-r--r--src/rebar_prv_as.erl12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rebar_prv_as.erl b/src/rebar_prv_as.erl
index ead7b01..b4f7ac4 100644
--- a/src/rebar_prv_as.erl
+++ b/src/rebar_prv_as.erl
@@ -37,6 +37,7 @@ do(State) ->
[] ->
{error, "At least one profile must be specified when using `as`"};
_ ->
+ warn_on_empty_profile(Profiles, State),
State1 = rebar_state:apply_profiles(State, [list_to_atom(X) || X <- Profiles]),
State2 = rebar_plugins:project_apps_install(State1),
{FirstTask, FirstTaskArgs} = hd(Tasks),
@@ -89,3 +90,14 @@ comma_or_end(["," ++ Profile|Rest], Acc) ->
profiles([Profile|Rest], Acc);
comma_or_end(Tasks, Acc) ->
{lists:reverse(Acc), rebar_utils:args_to_tasks(Tasks)}.
+
+%% If a profile is used by 'as' but has no entry under `profile` within
+%% the top level rebar.config or any project app's rebar.config print a warning.
+%% This is just to help developers, in case they forgot to define a profile but
+%% thought it was being used.
+warn_on_empty_profile(Profiles, State) ->
+ ProjectApps = rebar_state:project_apps(State),
+ DefinedProfiles = rebar_state:get(State, profiles, []) ++
+ lists:flatten([rebar_app_info:get(AppInfo, profiles, []) || AppInfo <- ProjectApps]),
+ [?WARN("No entry for profile ~s in config.", [Profile]) ||
+ Profile <- Profiles, not(lists:keymember(list_to_atom(Profile), 1, DefinedProfiles))].