From 625f76f4cd795162deaacd3a372ea979136b42c3 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 3 Oct 2015 11:20:09 -0500 Subject: print a warning if a profile in 'as' has no config entry --- src/rebar_prv_as.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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))]. -- cgit v1.1