diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-01-18 09:35:07 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-01-18 09:35:07 -0600 |
commit | fe4a10141baa00e33e0c6f04f2a67b80107729b7 (patch) | |
tree | 64102f90c1001ed2a9ec9dc7ce33843b36d00cb7 | |
parent | f45387f7955d497bfd3f1e5d4b0ad845669d7d92 (diff) |
do provider returns the error of the first provider to fail and stops
-rw-r--r-- | src/rebar_prv_do.erl | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl index c2bbe2b..5dec7d8 100644 --- a/src/rebar_prv_do.erl +++ b/src/rebar_prv_do.erl @@ -33,13 +33,21 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> Tasks = args_to_tasks(rebar_state:command_args(State)), - lists:foldl(fun(TaskArgs, {ok, StateAcc}) -> - [TaskStr | Args] = string:tokens(TaskArgs, " "), - Task = list_to_atom(TaskStr), - StateAcc1 = rebar_state:set(StateAcc, task, Task), - StateAcc2 = rebar_state:command_args(StateAcc1, Args), - rebar_core:process_command(StateAcc2, Task) - end, {ok, State}, Tasks). + do_tasks(Tasks, State). + +do_tasks([], State) -> + {ok, State}; +do_tasks([TaskArgs | Tail], State) -> + [TaskStr | Args] = string:tokens(TaskArgs, " "), + Task = list_to_atom(TaskStr), + State1 = rebar_state:set(State, task, Task), + State2 = rebar_state:command_args(State1, Args), + case rebar_core:process_command(State2, Task) of + {ok, State3} -> + do_tasks(Tail, State3); + Error -> + Error + end. -spec format_error(any()) -> iolist(). format_error(Reason) -> |