Skip to content
Persists configuration files and puts the current app in a module attribute.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
.travis.yml
README.md
mix.exs
mix.lock

README.md

PersistConfig

Build Status

Persists configuration files and puts the current app in a module attribute.

use PersistConfig

Supports the following options:

  • :app - module attribute to hold the current app, defaults to :app
  • :files - (wildcard) paths, defaults to ["config/persist*.exs"]

Option :files lists the configuration files to be persisted. These are typically imported in the config/config.exs file. For example: import_config "persist_this_config.exs".

Each entry represents a (wildcard) path relative to the root. If the list is or ends up being empty, no files are persisted.

When your project is used as a dependency, this package will allow the specified configuration files to be persisted.

For example, if you configured some path to read an external file and want to still read that file when your app is a dependency (without any path configuration in the parent app).

Usage

use PersistConfig, files: ["config/persist_path.exs"]
...
@path Application.get_env(@app, :path)
use PersistConfig, app :my_app
...
@my_attr Application.get_env(@my_app, :my_attr)

Installation

Add persist_config to your list of dependencies in mix.exs. Also include the configuration files to be persisted in the package definition of mix.exs as shown below:

def project do
  [
    app: :your_app,
    ...
    deps: deps(),
    package: package(),
    ...
  ]
end
...
def deps do
  [
    {:persist_config, "~> 0.2"}
  ]
end
...
defp package do
  [
    files: ["lib", "mix.exs", "README*", "config/persist*.exs"],
    maintainers: ["***"],
    licenses: ["***"],
    links: %{...}
  ]
end
You can’t perform that action at this time.