Rebar3/Mix: If dev profile/environment, enable tools automatically

This commit is contained in:
Badlop 2024-02-20 17:30:37 +01:00
parent 4431fbbe5a
commit 9275bf40b2
2 changed files with 19 additions and 3 deletions

View File

@ -187,10 +187,14 @@ defmodule Ejabberd.MixProject do
{:ok, path} ->
path
end
case :file.consult(filepath) do
config2 = case :file.consult(filepath) do
{:ok,config} -> config
_ -> [stun: true, zlib: true]
end
case Mix.env() do
:dev -> List.keystore(config2, :tools, 0, {:tools, true})
_ -> config2
end
end
defp config(key) do

View File

@ -6,10 +6,22 @@
{elixir, true} -> [elixir, iex, logger, mix];
_ -> []
end,
Tools = case lists:keyfind(tools, 1, Terms) of
{tools, true} -> [observer]; % for `ejabberdctl etop`
ProfileEnvironmentVariable = os:getenv("REBAR_PROFILE"),
AsProfiles = case lists:dropwhile(fun("as") -> false; (_) -> true end,
init:get_plain_arguments()) of
["as", Profiles | _] -> string:split(Profiles, ",");
_ -> []
end,
Terms2 = case lists:member("dev", [ProfileEnvironmentVariable | AsProfiles]) of
true -> lists:keystore(tools, 1, Terms, {tools, true});
false -> Terms
end,
Tools = case lists:keyfind(tools, 1, Terms2) of
{tools, true} -> [observer];
_ -> []
end,
{[lists:keyfind(description, 1, Terms),
lists:keyfind(vsn, 1, Terms),
{env, [{enabled_backends, EBs}]}