dwyl / elixir-pre-commit

✅ Pre-commit hooks for Elixir projects
GNU General Public License v2.0
46 stars 10 forks source link

Re-compile when config changes #18

Open finnhodgkin opened 6 years ago

finnhodgkin commented 6 years ago

We need to work out how to re-compile the pre_commit task when the config changes.

Example: A user sets up pre_commit for a project with just test in the config. The next day, the user adds credo --strict to the config, but the pre_commit doesn't update :cry:

Currently the only way to force an update is to delete the build folder and recompile.

finnhodgkin commented 6 years ago

A temporary fix for this is to include a section in the docs advising people to run mix clean --deps after changing pre_commit configuration.

finnhodgkin commented 6 years ago

I think the envy module reloads module configs so maybe we could take a look there at some point.

Update with potential fix

 @doc """
  Reloads `config/config.exs`. This function can be used to reload configuration
  that relies on environment variables set by Envy.
  This workaround is necessary since config files don't have
  access to dependencies.
  """
  def reload_config do
    Mix.Config.read!("config/config.exs") |> Mix.Config.persist
  end