aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sedov <[email protected]>2016-10-06 19:49:31 +0300
committerAlexander Sedov <[email protected]>2016-10-06 19:49:31 +0300
commit16f75eab97d80b4952ee5f8b786d7dc3f3111441 (patch)
tree1f5848fbf6a3d8ea0307187665bf7e652d40bfc5
parentcf68577c1499c64c7b154160fffe14cd57fbb6ec (diff)
downloadrelx-16f75eab97d80b4952ee5f8b786d7dc3f3111441.tar.gz
relx-16f75eab97d80b4952ee5f8b786d7dc3f3111441.tar.bz2
relx-16f75eab97d80b4952ee5f8b786d7dc3f3111441.zip
Fixed overlay_vars handling.
Overlay_vars obey order, you cannot just umerge them. Additionally, command line overrides should be more powerful than config values.
-rw-r--r--src/rlx_config.erl14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index d18f5f1..1dbfa13 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -265,7 +265,7 @@ load_terms({output_dir, OutputDir}, {ok, State}) ->
load_terms({overlay_vars, OverlayVars}, {ok, State}) ->
CurrentOverlayVars = rlx_state:get(State, overlay_vars),
NewOverlayVars0 = list_of_overlay_vars_files(OverlayVars),
- NewOverlayVars1 = lists:umerge(lists:usort(NewOverlayVars0), lists:usort(CurrentOverlayVars)),
+ NewOverlayVars1 = CurrentOverlayVars ++ NewOverlayVars0,
{ok, rlx_state:put(State, overlay_vars, NewOverlayVars1)};
load_terms({Name, Value}, {ok, State})
when erlang:is_atom(Name) ->
@@ -310,7 +310,6 @@ merge_configs([{Key, Value} | CliTerms], ConfigTerms) ->
case Key of
X when X =:= lib_dirs
; X =:= goals
- ; X =:= overlay_vars
; X =:= overrides ->
case lists:keyfind(Key, 1, ConfigTerms) of
{Key, Value2} ->
@@ -319,6 +318,17 @@ merge_configs([{Key, Value} | CliTerms], ConfigTerms) ->
false ->
merge_configs(CliTerms, ConfigTerms++[{Key, Value}])
end;
+ overlay_vars ->
+ case lists:keyfind(overlay_vars, 1, ConfigTerms) of
+ {_, [H | _] = Vars} when is_list(H) ->
+ MergedValue = Vars ++ Value,
+ merge_configs(CliTerms, lists:keyreplace(overlay_vars, 1, ConfigTerms, {Key, MergedValue}));
+ {_, Vars} when is_list(Vars) ->
+ MergedValue = [Vars | Value],
+ merge_configs(CliTerms, lists:keyreplace(overlay_vars, 1, ConfigTerms, {Key, MergedValue}));
+ false ->
+ merge_configs(CliTerms, ConfigTerms++[{Key, Value}])
+ end;
_ ->
merge_configs(CliTerms, lists:reverse(lists:keystore(Key, 1, lists:reverse(ConfigTerms), {Key, Value})))
end.