summaryrefslogtreecommitdiff
path: root/src/rebar_config.erl
diff options
context:
space:
mode:
authorTim Watson <watson.timothy@gmail.com>2011-08-01 08:12:36 +0100
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-08-18 15:35:30 +0200
commit5bb536f83985dfb840cac7c59c5473af1cae12bb (patch)
tree6b0fec6be69f4f41d28b308730001c0092fdb342 /src/rebar_config.erl
parentda31f90d1dc1674c5ad1e084fce897e5fdd5f07b (diff)
downloadrebar-5bb536f83985dfb840cac7c59c5473af1cae12bb.tar.gz
Respect the --config switch when given
Currently the --config switch does not work because when loading a new rebar config the global setting is ignored for all paths. This patch provides a check when loading new rebar config to see whether or not the current config path matches the `base_dir` set in global conf, which produces the expected behaviour.
Diffstat (limited to 'src/rebar_config.erl')
-rw-r--r--src/rebar_config.erl21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 9d2acf3..06396d8 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -26,7 +26,7 @@
%% -------------------------------------------------------------------
-module(rebar_config).
--export([new/0, new/1,
+-export([new/0, new/1, base_config/1,
get/3, get_local/3, get_list/3,
get_all/2,
set/3,
@@ -48,9 +48,13 @@
%% Public API
%% ===================================================================
+base_config(#config{opts=Opts0}) ->
+ ConfName = rebar_config:get_global(config, "rebar.config"),
+ new(Opts0, ConfName).
+
new() ->
#config { dir = rebar_utils:get_cwd(),
- opts = []}.
+ opts = [] }.
new(ConfigFile) when is_list(ConfigFile) ->
case consult_file(ConfigFile) of
@@ -60,17 +64,10 @@ new(ConfigFile) when is_list(ConfigFile) ->
Other ->
?ABORT("Failed to load ~s: ~p~n", [ConfigFile, Other])
end;
-new(#config{opts=Opts0}=ParentConfig)->
- %% If we are at the top level we might want to load another rebar.config
- %% We can be certain that we are at the top level if we don't have any
- %% configs yet since if we are at another level we must have some config.
- ConfName = case ParentConfig of
- {config, _, []} ->
- rebar_config:get_global(config, "rebar.config");
- _ ->
- "rebar.config"
- end,
+new(_ParentConfig=#config{opts=Opts0})->
+ new(Opts0, "rebar.config").
+new(Opts0, ConfName) ->
%% Load terms from rebar.config, if it exists
Dir = rebar_utils:get_cwd(),
ConfigFile = filename:join([Dir, ConfName]),