summaryrefslogtreecommitdiff
path: root/src/rebar_file_utils.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2019-03-29 11:49:14 -0400
committerGitHub <noreply@github.com>2019-03-29 11:49:14 -0400
commite42eecc93203e37f96db60b628356f718f9eb1f6 (patch)
tree884b8abe552bbe09f76148aa95e9d0431f22a8d7 /src/rebar_file_utils.erl
parentcc788f1ff3c2c845cda19f27291309effb94511a (diff)
parent86d261dbf1653a7cc074f7749a19b211e53cca0a (diff)
Merge pull request #2036 from ferd/shell-support-cfg-src
Attempt at support sys_config_src in shell
Diffstat (limited to 'src/rebar_file_utils.erl')
-rw-r--r--src/rebar_file_utils.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index 0e0dfe3..b2f34f0 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -28,6 +28,7 @@
-export([try_consult/1,
consult_config/2,
+ consult_config_terms/2,
format_error/1,
symlink_or_copy/2,
rm_rf/1,
@@ -66,6 +67,8 @@ try_consult(File) ->
throw(?PRV_ERROR({bad_term_file, File, Reason}))
end.
+%% @doc Parse a sys.config file and return the configuration terms
+%% for all its potentially nested configs.
-spec consult_config(rebar_state:t(), string()) -> [[tuple()]].
consult_config(State, Filename) ->
Fullpath = filename:join(rebar_dir:root_dir(State), Filename),
@@ -74,6 +77,18 @@ consult_config(State, Filename) ->
[T] -> T;
[] -> []
end,
+ consult_config_terms(State, Config).
+
+%% @doc From a parsed sys.config file, expand all the terms to include
+%% its potential nested configs. It is also possible that no sub-terms
+%% (i.e. the config file does not refer to "some/other/file.config")
+%% that the input term is returned as-is.
+%%
+%% This function is added mostly to help with variable substitution
+%% and evaluation of 'sys.config.src' files, giving a way to handle
+%% expansion that is separate from regular config handling.
+-spec consult_config_terms(rebar_state:t(), [tuple()]) -> [[tuple()]].
+consult_config_terms(State, Config) ->
JoinedConfig = lists:flatmap(
fun (SubConfig) when is_list(SubConfig) ->
case lists:suffix(".config", SubConfig) of