blob: 103d3a3c2a824e117061dd053872203e740a6756 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-module(rebar_packages).
-export([get_packages/1]).
-include("rebar.hrl").
-spec get_packages(rebar_state:t()) -> {list(), rlx_depsolver:t()}.
get_packages(State) ->
RebarDir = rebar_state:get(State, global_rebar_dir, filename:join(os:getenv("HOME"), ".rebar")),
PackagesFile = filename:join(RebarDir, "packages"),
case ec_file:exists(PackagesFile) of
true ->
try
{ok, Binary} = file:read_file(PackagesFile),
binary_to_term(Binary)
catch
_:_ ->
?ERROR("Bad packages index, try to fix with `rebar update`~n", []),
{[], rlx_depsolver:new()}
end;
false ->
{[], rlx_depsolver:new()}
end.
|