diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-11-10 20:40:56 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-11-10 20:40:56 -0600 |
commit | 6cae428058eb433864538f2e0c4a8fd5dd432f1c (patch) | |
tree | 8fb31a81993103476932550bc309ec0f4dbe1bce /src | |
parent | 768af3b9060a8234af03e24a7fb31c8bd5d32471 (diff) |
use CONFIG_DIR of rebar3 for config directories
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar3.erl | 5 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 2 | ||||
-rw-r--r-- | src/rebar_packages.erl | 3 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 4 | ||||
-rw-r--r-- | src/rebar_templater.erl | 8 | ||||
-rw-r--r-- | src/rebar_utils.erl | 7 |
6 files changed, 18 insertions, 11 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl index ab874e5..40f80d3 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -143,8 +143,9 @@ init_config() -> Config end, - %% If $HOME/.rebar/config exists load and use as global config - GlobalConfigFile = filename:join([os:getenv("HOME"), ".rebar", "config"]), + %% If $HOME/.rebar3/config exists load and use as global config + Home = rebar_utils:home_dir(), + GlobalConfigFile = filename:join([Home, ?CONFIG_DIR, "config"]), State = case filelib:is_regular(GlobalConfigFile) of true -> ?DEBUG("Load global config file ~p", diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 504eb81..1277242 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -418,7 +418,7 @@ check_erlcinfo(Config, _) -> [erlcinfo_file(Config)]). erlcinfo_file(_Config) -> - filename:join([rebar_utils:get_cwd(), ".rebar", ?ERLCINFO_FILE]). + filename:join([rebar_utils:get_cwd(), ?CONFIG_DIR, ?ERLCINFO_FILE]). init_erlcinfo(Config, Erls) -> G = restore_erlcinfo(Config), diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index cd979fa..7974fda 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -6,7 +6,8 @@ -spec get_packages(rebar_state:t()) -> {rebar_dict(), rlx_depsolver:t()}. get_packages(State) -> - RebarDir = rebar_state:get(State, global_rebar_dir, filename:join(os:getenv("HOME"), ".rebar")), + Home = rebar_utils:home_dir(), + RebarDir = rebar_state:get(State, global_rebar_dir, filename:join(Home, ?CONFIG_DIR)), PackagesFile = filename:join(RebarDir, "packages"), case ec_file:exists(PackagesFile) of true -> diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index eb7727b..ce6350b 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -35,8 +35,8 @@ do(State) -> ?INFO("Updating package index...", []), try Url = url(State), - {ok, [[Home]]} = init:get_argument(home), - PackagesFile = filename:join([Home, ".rebar", "packages"]), + Home = rebar_utils:home_dir(), + PackagesFile = filename:join([Home, ?CONFIG_DIR, "packages"]), filelib:ensure_dir(PackagesFile), {ok, _RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile} ,{sync, true}]) diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index 40f3165..cd0f5d4 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -143,8 +143,8 @@ default_variables() -> %% Load variable definitions from the 'Globals' file in the home template %% directory global_variables() -> - {ok, [[Home]]} = init:get_argument(home), - GlobalFile = filename:join([Home, ?HOME_DIR, "templates", "globals"]), + Home = rebar_utils:home_dir(), + GlobalFile = filename:join([Home, ?CONFIG_DIR, "templates", "globals"]), case file:consult(GlobalFile) of {error, enoent} -> []; {ok, Data} -> proplists:get_value(variables, Data, []) @@ -270,8 +270,8 @@ find_escript_templates(Files) -> %% Fetch template indexes that sit on disk in the user's HOME find_disk_templates(State) -> OtherTemplates = find_other_templates(State), - {ok, [[Home]]} = init:get_argument(home), - HomeFiles = rebar_utils:find_files(filename:join([Home, ?HOME_DIR, "templates"]), + Home = rebar_utils:home_dir(), + HomeFiles = rebar_utils:find_files(filename:join([Home, ?CONFIG_DIR, "templates"]), ?TEMPLATE_RE), LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE, true), [{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles]. diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index bd0c8c2..3309c24 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -26,7 +26,8 @@ %% ------------------------------------------------------------------- -module(rebar_utils). --export([droplast/1, +-export([home_dir/0, + droplast/1, filtermap/2, get_cwd/0, is_arch/1, @@ -66,6 +67,10 @@ %% Public API %% ==================================================================== +home_dir() -> + {ok, [[Home]]} = init:get_argument(home), + Home. + droplast(L) -> lists:reverse(tl(lists:reverse(L))). |