mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 19:21:34 +00:00
Introduce -k flag
This commit is contained in:
parent
ebdb25c5cc
commit
a7d64deb43
2 changed files with 44 additions and 24 deletions
|
@ -53,7 +53,7 @@ main(Args) ->
|
||||||
case catch(run(Args)) of
|
case catch(run(Args)) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, failed} ->
|
rebar_abort ->
|
||||||
rebar_utils:delayed_halt(1);
|
rebar_utils:delayed_halt(1);
|
||||||
Error ->
|
Error ->
|
||||||
%% Nothing should percolate up from rebar_core;
|
%% Nothing should percolate up from rebar_core;
|
||||||
|
@ -162,6 +162,9 @@ parse_args(Args) ->
|
||||||
rebar_config:set_global(enable_profiling,
|
rebar_config:set_global(enable_profiling,
|
||||||
proplists:get_bool(profile, Options)),
|
proplists:get_bool(profile, Options)),
|
||||||
|
|
||||||
|
%% Setup flag to keep running after a single command fails
|
||||||
|
rebar_config:set_global(keep_going, proplists:get_bool(keep_going, Options)),
|
||||||
|
|
||||||
%% Set global variables based on getopt options
|
%% Set global variables based on getopt options
|
||||||
set_log_level(Options),
|
set_log_level(Options),
|
||||||
set_global_flag(Options, force),
|
set_global_flag(Options, force),
|
||||||
|
@ -304,7 +307,8 @@ option_spec_list() ->
|
||||||
{defines, $D, undefined, string, "Define compiler macro"},
|
{defines, $D, undefined, string, "Define compiler macro"},
|
||||||
{jobs, $j, "jobs", integer, JobsHelp},
|
{jobs, $j, "jobs", integer, JobsHelp},
|
||||||
{config, $C, "config", string, "Rebar config file to use"},
|
{config, $C, "config", string, "Rebar config file to use"},
|
||||||
{profile, $p, "profile", undefined, "Profile this run of rebar"}
|
{profile, $p, "profile", undefined, "Profile this run of rebar"},
|
||||||
|
{keep_going, $k, "keep-going", undefined, "Keep running after a command fails"}
|
||||||
].
|
].
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -64,14 +64,19 @@ skip_dirs() ->
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
process_commands([], _ParentConfig) ->
|
process_commands([], _ParentConfig) ->
|
||||||
case erlang:get(operations) of
|
AbortTrapped = rebar_config:get_global(abort_trapped, false),
|
||||||
0 ->
|
case {erlang:get(operations), AbortTrapped} of
|
||||||
%% none of the commands had an effect
|
{0, _} ->
|
||||||
|
%% None of the commands had any effect
|
||||||
|
?ABORT;
|
||||||
|
{_, true} ->
|
||||||
|
%% An abort was previously trapped
|
||||||
?ABORT;
|
?ABORT;
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
process_commands([Command | Rest], ParentConfig) ->
|
process_commands([Command | Rest], ParentConfig) ->
|
||||||
|
try
|
||||||
%% Reset skip dirs
|
%% Reset skip dirs
|
||||||
lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
|
lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
|
||||||
Operations = erlang:get(operations),
|
Operations = erlang:get(operations),
|
||||||
|
@ -92,7 +97,18 @@ process_commands([Command | Rest], ParentConfig) ->
|
||||||
end,
|
end,
|
||||||
%% Wipe out vsn cache to avoid invalid hits when
|
%% Wipe out vsn cache to avoid invalid hits when
|
||||||
%% dependencies are updated
|
%% dependencies are updated
|
||||||
ets:delete_all_objects(rebar_vsn_cache),
|
ets:delete_all_objects(rebar_vsn_cache)
|
||||||
|
catch
|
||||||
|
throw:rebar_abort ->
|
||||||
|
case rebar_config:get_global(keep_going, false) of
|
||||||
|
false ->
|
||||||
|
?ABORT;
|
||||||
|
true ->
|
||||||
|
?WARN("Continuing on after abort: ~p\n", [Rest]),
|
||||||
|
rebar_config:set_global(abort_trapped, true),
|
||||||
|
ok
|
||||||
|
end
|
||||||
|
end,
|
||||||
process_commands(Rest, ParentConfig).
|
process_commands(Rest, ParentConfig).
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue