Dotenvy.source
You're seeing just the function
source
, go back to Dotenvy module for more information.
Specs
source(files :: binary() | [binary()], opts :: keyword()) :: {:ok, %{optional(String.t()) => String.t()}} | {:error, any()}
Like Bash's source
command, this loads the given file(s) and sets the corresponding
system environment variables using a side effect function (&System.put_env/1
by default).
Files are processed in the order they are given. Values parsed from one file may override
values parsed from previous files: the last file parsed has final say. The :overwrite?
option determines how the parsed values will be merged with the existing system values.
Options
:side_effect
an arity 1 function called after the successful parsing of each of the given files. The default is&System.put_env/1
, which will have the effect of setting system environment variables based on the results of the file parsing.:overwrite?
boolean indicating whether or not values parsed from provided.env
files should overwrite existing system environment variables. Default:false
:parser
module that parses the given file(s). Overridable for testing. Default:Dotenv.Parser
:require_files
specifies which of the givenfiles
(if any) must be present. Whentrue
, all the listed files must exist. Whenfalse
, none of the listed files must exist. When some of the files are required and some are optional, provide a list specifying which files are required.:side_effect
an arity 1 function called after the successful parsing of each of the given files. The default is&System.put_env/1
, which will have the effect of setting system environment variables based on the results of the file parsing.:vars
a map with string keys representing the starting pool of variables. Default: output ofSystem.get_env/0
.
Examples
iex> Dotenvy.source(".env")
{:ok, %{
"PWD" => "/users/home",
"DATABASE_URL" => "postgres://postgres:postgres@localhost/myapp",
# ...etc...
}
}
# If you only want to return the parsed contents of the listed files
# ignoring system environment variables altogether
iex> Dotenvy.source(["file1", "file2"], side_effect: false, vars: %{})