diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-10-03 11:20:09 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-10-03 11:20:09 -0500 |
commit | 625f76f4cd795162deaacd3a372ea979136b42c3 (patch) | |
tree | c40f25fa7368078afb75900921da55d7eaf55812 | |
parent | 4177c75a7c709b615962b1a885c119a51ed0aab0 (diff) |
print a warning if a profile in 'as' has no config entry
-rw-r--r-- | src/rebar_prv_as.erl | 12 |
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))]. |