-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
It would be nice if you could provide a list of optional files (something like how vapor defines a hierarchy of files -- see https://hexdocs.pm/vapor/Vapor.Provider.Dotenv.html#module-file-hierarchy) so you can easily allow users to override default configurations with more specific options. I don't think it's wise to hard-code a list of files that will be looked for -- I think it's a lot nicer (and easier) if you let users supply their own hierarchy of files.
Currently, the following generates an error:
iex(1)> Dotenv.load([".env", ".env.test"])
** (File.Error) could not read file ".env.test": no such file or directory
(elixir 1.11.1) lib/file.ex:354: File.read!/1
(dotenv 3.1.0) lib/dotenv.ex:348: Dotenv.read_env_file/1
(dotenv 3.1.0) lib/dotenv.ex:242: Dotenv.load/1
(dotenv 3.1.0) lib/dotenv.ex:231: Dotenv.load/1
(dotenv 3.1.0) lib/dotenv.ex:232: Dotenv.load/1
iex(1)>
I think perhaps the default behavior should be to just quietly ignore a missing file. It would be nice to have an option to enforce that the files exist, e.g. maybe something like:
iex> Dotenv.load([".env", ".env.test"], must_exist?: true)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels