diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-11-08 17:42:36 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-11-08 17:42:36 -0600 |
commit | 77ae74932697c95d97aa9b80bd13be167c08968e (patch) | |
tree | 8a1d2c91a088ef3c9e3d1ac32715bc76c6bb82d1 /src | |
parent | 26192b2187bbb93df28ed7b603b26e49f04badc7 (diff) |
update package update provider
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_update.erl | 15 |
1 files changed, 8 insertions, 7 deletions
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), |