瀏覽代碼

Merge pull request #42 from tsloughter/master

Update error message and fix order of dir creation for deps
pull/44/head
Fred Hebert 10 年之前
父節點
當前提交
018c5ceba3
共有 3 個檔案被更改,包括 14 行新增30 行删除
  1. +5
    -5
      src/rebar3.erl
  2. +9
    -3
      src/rebar_fetch.erl
  3. +0
    -22
      src/rebar_utils.erl

+ 5
- 5
src/rebar3.erl 查看文件

@ -47,9 +47,9 @@ main(Args) ->
{ok, _State} -> {ok, _State} ->
ok; ok;
rebar_abort -> rebar_abort ->
rebar_utils:delayed_halt(1);
erlang:halt(1);
{error, rebar_abort} -> {error, rebar_abort} ->
rebar_utils:delayed_halt(1);
erlang:halt(1);
{error, {Module, Reason}} -> {error, {Module, Reason}} ->
case code:which(Module) of case code:which(Module) of
non_existing -> non_existing ->
@ -58,16 +58,16 @@ main(Args) ->
_ -> _ ->
?ERROR(Module:format_error(Reason), []) ?ERROR(Module:format_error(Reason), [])
end, end,
rebar_utils:delayed_halt(1);
erlang:halt(1);
{error, Error} when is_list(Error) -> {error, Error} when is_list(Error) ->
?ERROR(Error, []), ?ERROR(Error, []),
rebar_utils:delayed_halt(1);
erlang:halt(1);
Error -> Error ->
%% Nothing should percolate up from rebar_core; %% Nothing should percolate up from rebar_core;
%% Dump this error to console %% Dump this error to console
?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []), ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []),
?DEBUG("Uncaught error: ~p", [Error]), ?DEBUG("Uncaught error: ~p", [Error]),
rebar_utils:delayed_halt(1)
erlang:halt(1)
end. end.
%% Erlang-API entry point %% Erlang-API entry point

+ 9
- 3
src/rebar_fetch.erl 查看文件

@ -11,6 +11,8 @@
download_source/2, download_source/2,
needs_update/2]). needs_update/2]).
-export([format_error/1]).
-include("rebar.hrl"). -include("rebar.hrl").
%% map short versions of resources to module names %% map short versions of resources to module names
@ -28,14 +30,15 @@ download_source(AppDir, Source) ->
Module = get_resource_type(Source), Module = get_resource_type(Source),
TmpDir = ec_file:insecure_mkdtemp(), TmpDir = ec_file:insecure_mkdtemp(),
AppDir1 = ec_cnv:to_list(AppDir), AppDir1 = ec_cnv:to_list(AppDir),
ec_file:mkdir_p(AppDir1),
case Module:download(TmpDir, Source) of case Module:download(TmpDir, Source) of
{ok, _} -> {ok, _} ->
ec_file:mkdir_p(AppDir1),
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), code:del_path(filename:absname(filename:join(AppDir1, "ebin"))),
ec_file:remove(filename:absname(AppDir1), [recursive]), ec_file:remove(filename:absname(AppDir1), [recursive]),
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]), ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]),
true; true;
{tarball, File} -> {tarball, File} ->
ec_file:mkdir_p(AppDir1),
ok = erl_tar:extract(File, [{cwd, TmpDir} ok = erl_tar:extract(File, [{cwd, TmpDir}
,compressed]), ,compressed]),
BaseName = filename:basename(AppDir1), BaseName = filename:basename(AppDir1),
@ -46,8 +49,8 @@ download_source(AppDir, Source) ->
true true
end end
catch catch
_:E ->
{error, E}
_:_ ->
{error, {rebar_fetch, {fetch_fail, Source}}}
end. end.
-spec needs_update(file:filename_all(), rebar_resource:resource()) -> boolean() | {error, string()}. -spec needs_update(file:filename_all(), rebar_resource:resource()) -> boolean() | {error, string()}.
@ -60,6 +63,9 @@ needs_update(AppDir, Source) ->
true true
end. end.
format_error({fetch_fail, Source}) ->
io_lib:format("Failed to fetch and copy dep: ~p", [Source]).
get_resource_type({Type, Location}) -> get_resource_type({Type, Location}) ->
find_resource_module(Type, Location); find_resource_module(Type, Location);
get_resource_type({Type, Location, _}) -> get_resource_type({Type, Location, _}) ->

+ 0
- 22
src/rebar_utils.erl 查看文件

@ -45,7 +45,6 @@
vcs_vsn/3, vcs_vsn/3,
deprecated/3, deprecated/3,
deprecated/4, deprecated/4,
delayed_halt/1,
erl_opts/1, erl_opts/1,
indent/1, indent/1,
cleanup_code_path/1]). cleanup_code_path/1]).
@ -205,27 +204,6 @@ deprecated(Old, New, When) ->
"'~p' will be removed ~s.~n">>, "'~p' will be removed ~s.~n">>,
[Old, Old, New, Old, When]). [Old, Old, New, Old, When]).
-spec delayed_halt(integer()) -> no_return().
delayed_halt(Code) ->
%% Work around buffer flushing issue in erlang:halt if OTP older
%% than R15B01.
%% TODO: remove workaround once we require R15B01 or newer
%% R15B01 introduced erlang:halt/2
case erlang:is_builtin(erlang, halt, 2) of
true ->
halt(Code);
false ->
case os:type() of
{win32, nt} ->
timer:sleep(100),
halt(Code);
_ ->
halt(Code),
%% workaround to delay exit until all output is written
receive after infinity -> ok end
end
end.
%% @doc Return list of erl_opts %% @doc Return list of erl_opts
-spec erl_opts(rebar_state:t()) -> list(). -spec erl_opts(rebar_state:t()) -> list().
erl_opts(Config) -> erl_opts(Config) ->

Loading…
取消
儲存