diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-04-07 08:07:29 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-04-07 08:07:29 -0400 |
commit | e88aec9d32380787bd55fd46f2d16a63e3c7c690 (patch) | |
tree | 2791cba35ad40531d8d1f64e9e6608cefe0f3a4d /src | |
parent | 0844e27d5be33e0e87a7c24a2742631cc4f9262e (diff) | |
parent | 4ec226da34665280575c9bb9a00395c0fa923184 (diff) |
Merge pull request #1151 from filmor/recursive-sys-config
Recursively load configurations in shell
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_shell.erl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl index 365ed66..ab496c6 100644 --- a/src/rebar_prv_shell.erl +++ b/src/rebar_prv_shell.erl @@ -328,7 +328,8 @@ reread_config(State) -> ConfigList -> try [application:set_env(Application, Key, Val) - || {Application, Items} <- ConfigList, + || Config <- ConfigList, + {Application, Items} <- Config, {Key, Val} <- Items] catch _:_ -> ?ERROR("The configuration file submitted could not be read " @@ -391,7 +392,7 @@ add_test_paths(State) -> ok. % First try the --config flag, then try the relx sys_config --spec find_config(rebar_state:t()) -> [tuple()] | no_config. +-spec find_config(rebar_state:t()) -> [[tuple()]] | no_config. find_config(State) -> case first_value([fun find_config_option/1, fun find_config_rebar/1, @@ -439,11 +440,17 @@ find_config_relx(State) -> debug_get_value(sys_config, rebar_state:get(State, relx, []), no_value, "Found config from relx."). --spec consult_config(rebar_state:t(), string()) -> [tuple()]. +-spec consult_config(rebar_state:t(), string()) -> [[tuple()]]. consult_config(State, Filename) -> Fullpath = filename:join(rebar_dir:root_dir(State), Filename), ?DEBUG("Loading configuration from ~p", [Fullpath]), - case rebar_file_utils:try_consult(Fullpath) of + Config = case rebar_file_utils:try_consult(Fullpath) of [T] -> T; [] -> [] - end. + end, + SubConfigs = [consult_config(State, Entry ++ ".config") || + Entry <- Config, is_list(Entry) + ], + + [Config | lists:merge(SubConfigs)]. + |