diff options
Diffstat (limited to 'src/rebar_prv_update.erl')
-rw-r--r-- | src/rebar_prv_update.erl | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index bfe3ab6..e1648e2 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -23,40 +23,25 @@ init(State) -> provider_impl = ?MODULE, bare = false, deps = ?DEPS, - example = "rebar update cowboy", - short_desc = "Update package index or individual dependency.", + example = "rebar update", + short_desc = "Update package index.", desc = "", opts = []}), {ok, State1}. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - case rebar_state:command_args(State) of - [Name] -> - ?INFO("Updating ~s~n", [Name]), - Locks = rebar_state:get(State, locks, []), - case lists:keyfind(ec_cnv:to_binary(Name), 1, Locks) of - {_, _, _, Level} -> - Deps = rebar_state:get(State, deps), - Dep = lists:keyfind(list_to_atom(Name), 1, Deps), - rebar_prv_install_deps:handle_deps(State, [Dep], {true, ec_cnv:to_binary(Name), Level}), - {ok, State}; - false -> - {error, io_lib:format("No such dependency ~s~n", [Name])} - end; - [] -> - ?INFO("Updating package index...~n", []), - try - Url = url(State), + ?INFO("Updating package index...~n", []), + 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, RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile} - ,{sync, true}]) - catch - _:_ -> - {error, io_lib:format("Failed to write package index.~n", [])} - end + ec_file:mkdir_p(filename:join([os:getenv("HOME"), ".rebar"])), + PackagesFile = filename:join([os:getenv("HOME"), ".rebar", "packages"]), + {ok, RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile} + ,{sync, true}]) + catch + _:_ -> + {error, io_lib:format("Failed to write package index.~n", [])} end. url(State) -> |