diff options
author | Alexey Romanov <alexey.v.romanov@gmail.com> | 2011-02-21 12:41:20 +0300 |
---|---|---|
committer | Alexey Romanov <alexey.v.romanov@gmail.com> | 2011-02-21 12:41:20 +0300 |
commit | 7dc371d8a3b9a6e2ab9f814c0d2536cf638ceb99 (patch) | |
tree | 174193ae08d2824164ba99e63f696a6593ee63c6 /src/rebar_config.erl | |
parent | 2ceeb3272139b7569c8dabc215ca1e7063b0d385 (diff) | |
parent | 6056c63eed288736c912c82d6f36aa7dd055f9ca (diff) |
Merge branch 'master' of https://github.com/basho/rebar
Diffstat (limited to 'src/rebar_config.erl')
-rw-r--r-- | src/rebar_config.erl | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/rebar_config.erl b/src/rebar_config.erl index cba0e64..a030e2c 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -1,4 +1,4 @@ -%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 et %% ------------------------------------------------------------------- %% @@ -58,20 +58,23 @@ new(ParentConfig) -> %% Load terms from rebar.config, if it exists Dir = rebar_utils:get_cwd(), ConfigFile = filename:join([Dir, ConfName]), - case file:consult(ConfigFile) of - {ok, Terms} -> - %% Found a config file with some terms. We need to be able to - %% distinguish between local definitions (i.e. from the file - %% in the cwd) and inherited definitions. To accomplish this, - %% we use a marker in the proplist (since order matters) between - %% the new and old defs. - Opts = Terms ++ [local] ++ [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; - {error, enoent} -> - Opts = [local] ++ [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; - Other -> - Opts = undefined, % Keep erlc happy - ?ABORT("Failed to load ~s: ~p\n", [ConfigFile, Other]) - end, + Opts = case file:consult(ConfigFile) of + {ok, Terms} -> + %% Found a config file with some terms. We need to + %% be able to distinguish between local definitions + %% (i.e. from the file in the cwd) and inherited + %% definitions. To accomplish this, we use a marker + %% in the proplist (since order matters) between + %% the new and old defs. + Terms ++ [local] ++ + [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; + {error, enoent} -> + [local] ++ + [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; + Other -> + ?ABORT("Failed to load ~s: ~p\n", [ConfigFile, Other]) + end, + #config { dir = Dir, opts = Opts }. get(Config, Key, Default) -> @@ -91,7 +94,7 @@ set(Config, Key, Value) -> Config#config { opts = [{Key, Value} | Opts] }. set_global(jobs=Key, Value) when is_list(Value) -> - set_global(Key,list_to_integer(Value)); + set_global(Key, list_to_integer(Value)); set_global(jobs=Key, Value) when is_integer(Value) -> application:set_env(rebar_global, Key, erlang:max(1,Value)); set_global(Key, Value) -> |