mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Optimize list ops and error reporting in sh/2
This commit is contained in:
parent
a9a7d7c02b
commit
d9ef6fbd53
1 changed files with 11 additions and 11 deletions
|
@ -102,8 +102,8 @@ sh(Command0, Options0) ->
|
|||
case sh_loop(Port, OutputHandler, []) of
|
||||
{ok, _Output} = Ok ->
|
||||
Ok;
|
||||
{error, Rc} ->
|
||||
ErrorHandler(Command, Rc)
|
||||
{error, Err} ->
|
||||
ErrorHandler(Command, Err)
|
||||
end.
|
||||
|
||||
%% We need a bash shell to execute on windows
|
||||
|
@ -182,12 +182,12 @@ expand_code_path() ->
|
|||
|
||||
expand_sh_flag(return_on_error) ->
|
||||
{error_handler,
|
||||
fun(_Command, Rc) ->
|
||||
{error, Rc}
|
||||
fun(_Command, Err) ->
|
||||
{error, Err}
|
||||
end};
|
||||
expand_sh_flag({abort_on_error, Message}) ->
|
||||
{error_handler,
|
||||
fun(_Command, _Rc) ->
|
||||
fun(_Command, _Err) ->
|
||||
?ABORT(Message, [])
|
||||
end};
|
||||
expand_sh_flag(abort_on_error) ->
|
||||
|
@ -197,12 +197,12 @@ expand_sh_flag(use_stdout) ->
|
|||
{output_handler,
|
||||
fun(Line, Acc) ->
|
||||
?CONSOLE("~s", [Line]),
|
||||
[Acc | Line]
|
||||
[Line | Acc]
|
||||
end};
|
||||
expand_sh_flag({use_stdout, false}) ->
|
||||
{output_handler,
|
||||
fun(Line, Acc) ->
|
||||
[Acc | Line]
|
||||
[Line | Acc]
|
||||
end};
|
||||
expand_sh_flag({cd, _CdArg} = Cd) ->
|
||||
{port_settings, Cd};
|
||||
|
@ -210,8 +210,8 @@ expand_sh_flag({env, _EnvArg} = Env) ->
|
|||
{port_settings, Env}.
|
||||
|
||||
-spec log_and_abort(string(), integer()) -> no_return().
|
||||
log_and_abort(Command, Rc) ->
|
||||
?ABORT("~s failed with error: ~w\n", [Command, Rc]).
|
||||
log_and_abort(Command, {Rc, Output}) ->
|
||||
?ABORT("~s failed with error: ~w and output:~n~s~n", [Command, Rc, Output]).
|
||||
|
||||
sh_loop(Port, Fun, Acc) ->
|
||||
receive
|
||||
|
@ -226,9 +226,9 @@ sh_loop(Port, Fun, Acc) ->
|
|||
{Port, {data, {noeol, Line}}} ->
|
||||
sh_loop(Port, Fun, Fun(Line, Acc));
|
||||
{Port, {exit_status, 0}} ->
|
||||
{ok, lists:flatten(Acc)};
|
||||
{ok, lists:flatten(lists:reverse(Acc))};
|
||||
{Port, {exit_status, Rc}} ->
|
||||
{error, Rc}
|
||||
{error, {Rc, lists:flatten(lists:reverse(Acc))}}
|
||||
end.
|
||||
|
||||
beam_to_mod(Dir, Filename) ->
|
||||
|
|
Loading…
Reference in a new issue