diff --git a/README.md b/README.md index 5012ffd..96a167c 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,14 @@ For example, to watch `.js` and `.css` files add this to your `config.exs`: config :exsync, extra_extensions: [".js", ".css"] ``` +`:exclusions` - List of regular expressions that, if matched, exclude a file from being noticed by exsync. + +For example, to exclude Emacs temporary files: + +```elixir +config :exsync, exclusions: [~r/#/] +``` + `:logging_enabled` - Set to false to disable logging (default true) `:reload_callback` - A callback [MFA](https://codereviewvideos.com/blog/what-is-mfa-in-elixir/) that is called when a set of files are done reloading. Can be used to implement your own special handling to react to file reloads. diff --git a/lib/exsync/config.ex b/lib/exsync/config.ex index c063bc3..173fac6 100644 --- a/lib/exsync/config.ex +++ b/lib/exsync/config.ex @@ -126,6 +126,14 @@ defmodule ExSync.Config do ) end + def src_exclusions do + Application.get_env( + :exsync, + :exclusions, + Application.get_env(:exsync, :exclusions, []) + ) + end + def application do :exsync end diff --git a/lib/exsync/src_monitor.ex b/lib/exsync/src_monitor.ex index c47b6e5..730c738 100644 --- a/lib/exsync/src_monitor.ex +++ b/lib/exsync/src_monitor.ex @@ -37,8 +37,14 @@ defmodule ExSync.SrcMonitor do # isolation to trigger things. matching_event? = :modified in events + included? = + !Enum.any?( + ExSync.Config.src_exclusions(), + &Regex.match?(&1, path) + ) + state = - if matching_extension? && matching_event? do + if matching_extension? && matching_event? && included? do maybe_recomplete(state) else state