Current section
Files
Jump to
Current section
Files
lib/ai/env.ex
defmodule AI.Env do
@moduledoc """
Loads dotenv files into the process environment.
"""
@doc """
Loads `.env` and `.env.local` unless already set in the OS env.
"""
def load do
if Code.ensure_loaded?(Dotenvy) do
vars =
Dotenvy.source!(
[
System.get_env("DOTENV_PATH") || ".env",
".env.local"
],
ignore_missing: true
)
Enum.each(vars, fn {key, value} ->
if is_nil(System.get_env(key)) do
System.put_env(key, value)
end
end)
end
:ok
end
end