-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrebar.config.script
31 lines (31 loc) · 1.18 KB
/
rebar.config.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
case os:getenv("BUNDLER_CONFIG") of
false -> CONFIG;
[] -> CONFIG;
BundlerConfig ->
ConsultRet =
case filelib:is_file(BundlerConfig) of
true ->
file:consult(BundlerConfig);
false ->
file:write_file("/tmp/mydeps", BundlerConfig),
file:consult("/tmp/mydeps")
end,
case ConsultRet of
{ok, Terms} ->
io:format(user, "TERMS ~p~n", [Terms]),
lists:foldl(
fun({K, V}, AccCONFIG) ->
case lists:keyfind(K, 1, AccCONFIG) of
false ->
[{K, V} | AccCONFIG];
{K, Existing} when is_list(Existing) ->
lists:keyreplace(K, 1, AccCONFIG, {K, lists:usort(V ++ Existing)});
{K, _} ->
lists:keyreplace(K, 1, AccCONFIG, {K, V})
end
end, CONFIG, Terms);
{error, Reason} ->
io:format(user, "can't template Rebar3 config ~p~n", [Reason]),
exit(1)
end
end.