View Source Igniter.Project.Config (igniter v0.3.16)
Codemods and utilities for modifying Elixir config files.
Summary
Functions
Sets a config value in the given configuration file, updating it with updater
if it is already set.
Sets a config value in the given configuration file, if it is not already set.
Returns true
if the given configuration path is set somewhere after the provided zipper, or in the given configuration file.
Same as configures_key?/4
but accepts a Zipper.
If the last argument is key, checks if either config :root_key, :key, ...
or config :root_key, key: ...
is set.
Same as configures_root_key?/3
but accepts a Zipper instead.
Checks if either config :root_key, _
or config :root_key, _, _
is present
in the provided config file.
Modifies elixir configuration code starting at the configured zipper.
Functions
configure(igniter, file_name, app_name, config_path, value, opts \\ [])
View Source@spec configure( Igniter.t(), Path.t(), atom(), [atom()], term(), opts :: Keyword.t() ) :: Igniter.t()
Sets a config value in the given configuration file, updating it with updater
if it is already set.
Opts
:updater
- A function that takes a zipper at a currently configured value and returns a new zipper with the value updated.failure_message
- A message to display to the user if the configuration change is unsuccessful.
configure_new(igniter, file_path, app_name, config_path, value, opts \\ [])
View Source@spec configure_new( Igniter.t(), Path.t(), atom(), [atom()], term(), opts :: Keyword.t() ) :: Igniter.t()
Sets a config value in the given configuration file, if it is not already set.
Opts
failure_message
- A message to display to the user if the configuration change is unsuccessful.
@spec configures?(Sourceror.Zipper.t(), [atom()], atom()) :: boolean()
Returns true
if the given configuration path is set somewhere after the provided zipper, or in the given configuration file.
@spec configures_key?(Sourceror.Zipper.t(), atom(), atom() | [atom()]) :: boolean()
Same as configures_key?/4
but accepts a Zipper.
If the last argument is key, checks if either config :root_key, :key, ...
or config :root_key, key: ...
is set.
If the last argument is a keyword path, checks if
config :root_key, path_head, [...]
defines path_rest
or if
config :root_key, [...]
defines path
, where path_head
is the first
element of path
and path_rest
are the remaining elements.
Note: config_file_name
should not include the config/
prefix.
@spec configures_root_key?(Sourceror.Zipper.t(), atom()) :: boolean()
Same as configures_root_key?/3
but accepts a Zipper instead.
Checks if either config :root_key, _
or config :root_key, _, _
is present
in the provided config file.
Note: The config file name should not include the config/
prefix.
modify_configuration_code(zipper, config_path, app_name, value, updater \\ nil)
View Source@spec modify_configuration_code( Sourceror.Zipper.t(), [atom()], atom(), term(), (Sourceror.Zipper.t() -> {:ok, Sourceror.Zipper.t()} | :error) | nil ) :: Sourceror.Zipper.t()
Modifies elixir configuration code starting at the configured zipper.
If you want to set configuration, use configure/6
or configure_new/5
instead. This is a lower-level
tool for modifying configuration files when you need to adjust some specific part of them.