From fe4a10141baa00e33e0c6f04f2a67b80107729b7 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 18 Jan 2015 09:35:07 -0600 Subject: do provider returns the error of the first provider to fail and stops --- src/rebar_prv_do.erl | 22 +++++++++++++++------- 1 file 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) -> -- cgit v1.1