I have a top-level ~/.iex.exs
file, and from project-specific my_app/.iex.exs
files I require it as
global_settings = Path.expand("~/.iex.exs")
if File.exists?(global_settings), do: Code.require_file(global_settings)
I want some behaviour in a generic ~/.iex.exs
to rely on whether it’s required from the project’s one (typically run as iex -S mix
,) or it’s called during a standalone iex
invocation.
Is there more convenient way to do so than one of the below
config = try do Mix.Project.config() catch _, _ -> :nil end
# or
config = GenServer.whereis(Mix.ProjectStack) && Mix.Project.config()
The documentation says I am after Mix.Project.get/0
but it raises if run outside of mix
.