diff options
-rw-r--r-- | src/rebar_config.erl | 33 | ||||
-rw-r--r-- | src/rebar_core.erl | 5 | ||||
-rw-r--r-- | src/rebar_templater.erl | 6 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/rebar_config.erl b/src/rebar_config.erl index cba0e64..7da6900 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -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) -> diff --git a/src/rebar_core.erl b/src/rebar_core.erl index e8b4e57..f8eb6f5 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -453,10 +453,11 @@ execute(Command, Modules, Config, ModuleFile) -> ?FAIL; {Module, {error, _} = Other} -> ?ABORT("~p failed while processing ~s in module ~s: ~s\n", - [Command, Dir, Module, io_lib:print(Other, 1,80,-1)]); + [Command, Dir, Module, + io_lib:print(Other, 1, 80, -1)]); Other -> ?ABORT("~p failed while processing ~s: ~s\n", - [Command, Dir, io_lib:print(Other, 1,80,-1)]) + [Command, Dir, io_lib:print(Other, 1, 80, -1)]) end end. diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index e251f40..b241fd5 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -263,8 +263,8 @@ write_file(Output, Data, Force) -> %% perform the function if we're allowed, %% otherwise just process the next template - if - Force =:= "1"; FileExists =:= false -> + case Force =:= "1" orelse FileExists =:= false of + true -> ok = filelib:ensure_dir(Output), if {Force, FileExists} =:= {"1", true} -> @@ -280,7 +280,7 @@ write_file(Output, Data, Force) -> ?ABORT("Failed to write output file ~p: ~p\n", [Output, Reason]) end; - true -> + false -> {error, exists} end. |