From 12726111bc827274fb71141ddaf6911b8e02d99c Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sun, 1 Mar 2015 20:32:57 -0800 Subject: `add_to_profile/3` function added to `rebar_state` --- src/rebar_state.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/rebar_state.erl') diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 39e0e88..8170b8d 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -15,7 +15,7 @@ command_args/1, command_args/2, command_parsed_args/1, command_parsed_args/2, - apply_profiles/2, + add_to_profile/3, apply_profiles/2, dir/1, dir/2, create_logic_providers/2, @@ -97,7 +97,6 @@ new(ParentState, Config, Dir) -> D = proplists:get_value(deps, Config, []), dict:from_list([{{deps, default}, D} | Config]) end, - NewOpts = dict:merge(fun(_Key, Value1, _Value2) -> Value1 end, LocalOpts, Opts), @@ -188,6 +187,13 @@ apply_overrides(State=#state_t{overrides=Overrides}, AppName) -> StateAcc end, State2, Overrides). +add_to_profile(State, Profile, KVs) when is_atom(Profile), is_list(KVs) -> + Profiles = rebar_state:get(State, profiles, []), + ProfileOpts = dict:from_list(proplists:get_value(Profile, Profiles, [])), + NewOpts = merge_opts(Profile, dict:from_list(KVs), ProfileOpts), + NewProfiles = [{Profile, dict:to_list(NewOpts)}|lists:keydelete(Profile, 1, Profiles)], + rebar_state:set(State, profiles, NewProfiles). + apply_profiles(State, Profile) when not is_list(Profile) -> apply_profiles(State, [Profile]); apply_profiles(State, [default]) -> -- cgit v1.1