Sigra.Env (Sigra v0.2.4)

Copy Markdown View Source

Release-safe Mix environment detection.

In a Mix release, the :mix application is intentionally excluded (Mix is a build-time tool). Code that calls Mix.env/0 at runtime from inside a release raises UndefinedFunctionError.

This helper guards the call with function_exported?/3 and falls back to :prod when Mix is not loaded.

Summary

Functions

Returns the current Mix environment, or :prod when Mix is unavailable (e.g., inside a release).

Functions

current()

@spec current() :: atom()

Returns the current Mix environment, or :prod when Mix is unavailable (e.g., inside a release).

Examples

iex> Sigra.Env.current() in [:dev, :test, :prod]
true