Hi,
I'm curious what you'd think of having a variant of
Mix.Config.import_config/1 that doesn't raise an error when the config file
is missing. I'd like to be able to import optional configs, like
config/prod.secret.exs if it exists, but not error if it's missing. Right
now, I write my config/config.exs like this
# config/config.exs
use Mix.Config
config :my_app, setting: true
#Import env specific config
import_config "#{Mix.env()}.exs"
# Import secrets across all environments
try do
import_config "config.secret.exs"
rescue
Code.LoadError -> :ok
end
# Import env specific settings
try do
import_config "#{Mix.env()}.secret.exs"
rescue
Code.LoadError -> :ok
end
If you include a wildcard in the path to import_config/1 it doesn't raise
an error if no files are found. What would you think about adding an
additional argument to import_config that allows me to flag the import as
optional? Then I could write my config like this.
# config/config.exs
use Mix.Config
config :my_app, setting: true
#Import env specific config
import_config "#{Mix.env()}.exs"
# Import secrets across all environments
import_config "config.secret.exs", optional: true
# Import env specific settings
import_config "#{Mix.env()}.secret.exs", optional: true
Any suggestions or different approaches I should try would be greatly
appreciated!
Thanks,
Aaron Renner
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/dca1f2df-aaf8-4967-b52b-d790fdad327b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.