diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-11-22 16:53:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-22 16:53:45 -0500 |
commit | 2c31f94858d66464cc5acfd4dbe74777f2f83453 (patch) | |
tree | edc7757c2ff6dbd950de3f1d1f6ff77ca890c261 /src | |
parent | 5f6d1d88acc2d8e228b569f6cc8d99da7fedbdf9 (diff) | |
parent | 5323fdc377d6034cdb625547600144881ae1af46 (diff) |
Merge pull request #1387 from ericmj/emj-rebar-config-env
Always read REBAR_CONFIG env var when loading config
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar.hrl | 1 | ||||
-rw-r--r-- | src/rebar3.erl | 7 | ||||
-rw-r--r-- | src/rebar_config.erl | 19 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/rebar.hrl b/src/rebar.hrl index f96ed5e..c94a84a 100644 --- a/src/rebar.hrl +++ b/src/rebar.hrl @@ -22,7 +22,6 @@ -define(DEFAULT_PLUGINS_DIR, "plugins"). -define(DEFAULT_TEST_DEPS_DIR, "test/lib"). -define(DEFAULT_RELEASE_DIR, "rel"). --define(DEFAULT_CONFIG_FILE, "rebar.config"). -define(CONFIG_VERSION, "1.1.0"). -define(DEFAULT_CDN, "https://repo.hex.pm/"). -define(REMOTE_PACKAGE_DIR, "tarballs"). diff --git a/src/rebar3.erl b/src/rebar3.erl index 47dc25a..4e7e284 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -149,12 +149,7 @@ init_config() -> Verbosity = log_level(), ok = rebar_log:init(command_line, Verbosity), - Config = case os:getenv("REBAR_CONFIG") of - false -> - rebar_config:consult_file(?DEFAULT_CONFIG_FILE); - ConfigFile -> - rebar_config:consult_file(ConfigFile) - end, + Config = rebar_config:consult(), Config1 = rebar_config:merge_locks(Config, rebar_config:consult_lock_file(?LOCK_FILE)), %% If $HOME/.config/rebar3/rebar.config exists load and use as global config diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 72bc6e9..5a35b87 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -26,7 +26,8 @@ %% ------------------------------------------------------------------- -module(rebar_config). --export([consult/1 +-export([consult/0 + ,consult/1 ,consult_app_file/1 ,consult_file/1 ,consult_lock_file/1 @@ -39,13 +40,19 @@ -include("rebar.hrl"). -include_lib("providers/include/providers.hrl"). +-define(DEFAULT_CONFIG_FILE, "rebar.config"). + %% =================================================================== %% Public API %% =================================================================== +-spec consult() -> [any()]. +consult() -> + consult_file(config_file()). + -spec consult(file:name()) -> [any()]. consult(Dir) -> - consult_file(filename:join(Dir, ?DEFAULT_CONFIG_FILE)). + consult_file(filename:join(Dir, config_file())). consult_app_file(File) -> consult_file_(File). @@ -298,3 +305,11 @@ check_newly_added_(Dep, LockedDeps) when is_atom(Dep) -> end; check_newly_added_(Dep, _) -> throw(?PRV_ERROR({bad_dep_name, Dep})). + +config_file() -> + case os:getenv("REBAR_CONFIG") of + false -> + ?DEFAULT_CONFIG_FILE; + ConfigFile -> + ConfigFile + end. |