summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrancisco Rojas <frojas@groupon.com>2016-04-06 21:16:25 -0700
committerFrancisco Rojas <frojas@groupon.com>2016-04-06 21:16:25 -0700
commit243e94391a4ac446cfe0c814750abfb014db9ac4 (patch)
tree5c0f9fc9ea5408bc4c8b0a0359c2e646e6ad80ee /src
parent2d1d251add285c6296e0ce1c12e2a9a961c2209b (diff)
Read env var REBAR_CACHE_DIR on rebar3 only once
Instead of reading every time that rebar_dir:global_cache_dir/1 is called
Diffstat (limited to 'src')
-rw-r--r--src/rebar3.erl13
-rw-r--r--src/rebar_dir.erl10
2 files changed, 12 insertions, 11 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index c1a1ae4..ff0ab6a 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -129,13 +129,20 @@ run_aux(State, RawArgs) ->
%% Initializing project_plugins which can override default providers
State6 = rebar_plugins:project_plugins_install(State5),
State7 = rebar_plugins:top_level_install(State6),
- State8 = rebar_state:default(State7, rebar_state:opts(State7)),
+ State8 = case os:getenv("REBAR_CACHE_DIR") of
+ false ->
+ State7;
+ ConfigFile ->
+ rebar_state:set(State7, global_rebar_dir, ConfigFile)
+ end,
+
+ State9 = rebar_state:default(State8, rebar_state:opts(State8)),
{Task, Args} = parse_args(RawArgs),
- State9 = rebar_state:code_paths(State8, default, code:get_path()),
+ State10 = rebar_state:code_paths(State9, default, code:get_path()),
- rebar_core:init_command(rebar_state:command_args(State9, Args), Task).
+ rebar_core:init_command(rebar_state:command_args(State10, Args), Task).
init_config() ->
%% Initialize logging system
diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl
index df05cdb..1ec58d4 100644
--- a/src/rebar_dir.erl
+++ b/src/rebar_dir.erl
@@ -94,14 +94,8 @@ global_config() ->
-spec global_cache_dir(rebar_dict()) -> file:filename_all().
global_cache_dir(Opts) ->
- RebarCacheDir = case os:getenv("REBAR_CACHE_DIR") of
- false ->
- Home = home_dir(),
- filename:join([Home, ".cache", "rebar3"]);
- ConfigFile ->
- ConfigFile
- end,
- rebar_opts:get(Opts, global_rebar_dir, RebarCacheDir).
+ Home = home_dir(),
+ rebar_opts:get(Opts, global_rebar_dir, filename:join([Home, ".cache", "rebar3"])).
local_cache_dir(Dir) ->
filename:join(Dir, ".rebar3").