View Source ExGuard.Guard (ExGuard v1.6.1)

Users use functions in this module to build config files.

guard("test")
|> command("mix text --color")
|> watch(~r{\.(ex|exs)$})
|> notification(:auto)

Summary

Functions

Sets command for given guard config.

Executes the command for a guard config.

Creates ExGuard config.

It can be used to exclude files and directories from the set of files being watched.

Sets notification for given guard config. By default notification is on.

notifies the result

Sets watch pattern for given guard config.

Functions

Link to this function

command(guard_struct, cmd)

View Source

Sets command for given guard config.

guard("test")
|> command("mix text --color")

Executes the command for a guard config.

If files is a list, append them to guard.cmd and executes it.

Link to this function

guard(title, opts \\ [])

View Source

Creates ExGuard config.

guard("test")

Options:

  • :run_on_start, set this option If you want to run the command when mix guard has been executed

  • :umbrella_app, set this option If you are running guard on the main directory of an umbrella project and using watch command to match changed filed with test

    guard("test", run_on_start: true, umbrella_app: true)

Link to this function

ignore(guard_struct, ignore_rule)

View Source

It can be used to exclude files and directories from the set of files being watched.

guard("text files")
|> ignore(~r/\.txt$/)
Link to this function

notification(guard_struct, atom)

View Source

Sets notification for given guard config. By default notification is on.

guard("test")
|> notification(:auto)

To turn off the notification set it to :off

guard("not notification")
|> notification(:off)

notifies the result

Link to this function

watch(guard_struct, pattern)

View Source

Sets watch pattern for given guard config.

To watch all Elixir and Erlang files set:

guard("Elixir/Erlang files")
|> watch(~r{\\.(erl|ex|exs|eex|xrl|yrl)\\z}i)

To only execute the command for specific files use:

guard("execute specific tests")
|> watch({~r{lib/(?<dir>.+)/(?<file>.+).ex$}, fn(m) -> "test/#{m["dir"]}/#{m["file"]}_test.exs" end})