diff options
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 15 |
2 files changed, 8 insertions, 9 deletions
diff --git a/rebar.config b/rebar.config index 2ba3ee2..c505ef9 100644 --- a/rebar.config +++ b/rebar.config @@ -1,8 +1,6 @@ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 ft=erlang et -{rebar_packages_url, "http://localhost:8080"}. - %% escript_incl_extra is for internal rebar-private use only. %% Do not use outside rebar. Config interface is not stable. {escript_incl_extra, [{"priv/templates/*", "."}, {"rebar/include/*", "."}]}. diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 0d388c8..4952ed2 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -32,23 +32,24 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - ?INFO("Updating package index...~n", []), + ?INFO("Updating package index...", []), try Url = url(State), - %{ok, [Home]} = init:get_argument(home), - ec_file:mkdir_p(filename:join([os:getenv("HOME"), ".rebar"])), - PackagesFile = filename:join([os:getenv("HOME"), ".rebar", "packages"]), + {ok, [[Home]]} = init:get_argument(home), + PackagesFile = filename:join([Home, ".rebar", "packages"]), + filelib:ensure_dir(PackagesFile), {ok, _RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile} ,{sync, true}]) catch _:_ -> - {error, io_lib:format("Failed to write package index.~n", [])} + {error, {?MODULE, package_index_write}} end, + {ok, State}. -spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}. -format_error(Reason, State) -> - {io_lib:format("~p", [Reason]), State}. +format_error(package_index_write, State) -> + {"Failed to write package index.", State}. url(State) -> SystemArch = erlang:system_info(system_architecture), |