Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slashmili/ex_guard
ExGuard is a mix command to handle events on file system modifications
https://github.com/slashmili/ex_guard
Last synced: 3 months ago
JSON representation
ExGuard is a mix command to handle events on file system modifications
- Host: GitHub
- URL: https://github.com/slashmili/ex_guard
- Owner: slashmili
- License: mit
- Created: 2016-03-15T00:34:13.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-07-08T16:15:30.000Z (7 months ago)
- Last Synced: 2024-10-02T14:47:46.442Z (4 months ago)
- Language: Elixir
- Homepage: https://hex.pm/packages/ex_guard
- Size: 576 KB
- Stars: 84
- Watchers: 4
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - ExGuard is a mix command to handle events on file system modifications. (Files and Directories)
- fucking-awesome-elixir - ex_guard - ExGuard is a mix command to handle events on file system modifications. (Files and Directories)
- awesome-elixir - ex_guard - ExGuard is a mix command to handle events on file system modifications. (Files and Directories)
README
# ExGuard
ExGuard is a mix command to handle events on file system modifications, ExGuard heavily borrowed ideas/art works from [Ruby Guard](https://github.com/guard/guard)
![ExGuard](https://github.com/slashmili/ex_guard/raw/master/logo.png)
[![Build Status](https://github.com/slashmili/ex_guard/actions/workflows/test.yml/badge.svg)](https://github.com/slashmili/ex_guard/actions)
[![Hex.pm](https://img.shields.io/hexpm/v/ex_guard.svg)](https://hex.pm/packages/ex_guard)
[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://hexdocs.pm/ex_guard/)
[![Hex.pm](https://img.shields.io/hexpm/dt/ex_guard.svg)](https://hex.pm/packages/ex_guard)
[![Deps Status](https://beta.hexfaktor.org/badge/all/github/slashmili/ex_guard.svg)](https://beta.hexfaktor.org/github/slashmili/ex_guard)
[![Hex.pm](https://img.shields.io/hexpm/l/ex_guard.svg)]()## Usage
1. Add `ex_guard` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:ex_guard, "~> 1.5", only: :dev}]
end
```2. Create a file named `.exguard.exs` in your root application directory:
```elixir
use ExGuard.Configguard("unit-test", run_on_start: true)
|> command("mix test --color")
|> watch(~r{\.(erl|ex|exs|eex|xrl|yrl)\z}i)
|> ignore(~r{deps})
|> notification(:auto)
```Look at below sample file for more fine-grained config.
3. Run `mix guard` as soon as you change any file with above pattern, the test gets executed
## Notification
Currently supports notification with tools:
* [Terminal Title](http://tldp.org/HOWTO/Xterm-Title-3.html) (Xterm)
* [TMux](http://tmux.github.io/) (Universal)
* [Terminal Notifier](https://github.com/julienXX/terminal-notifier) (mac only)
* [Notify Send](http://ss64.com/bash/notify-send.html) (linux distros)In order to _ExGuard_ sends notification, you need to make sure these tools are setup properly.
If you are using _ExGuard_ mainly for Elixir test you may turn the notification off and use [ExUnit Notifier](https://github.com/navinpeiris/ex_unit_notifier) instead.
## Why ExGuard and not mix-test.watch or eye_drops or XYZ
It's just a matter of taste!
With _ExGuard_ you can run multiple commands and the config looks nice.
```elixir
use ExGuard.Configguard("elixir test", run_on_start: true)
|> command("mix test --color")
#only run related phoenix test when a file changes
|> watch({~r{lib/(?.+_web)/(?.+)/(?.+).ex$}i, fn m -> "test/#{m["lib_dir"]}/#{m["dir"]}/#{m["file"]}_test.exs" end})
# only if the above pattern doesn't match try to match all elixir/erlang source
|> watch(~r{\.(erl|ex|exs|eex|xrl|yrl)\z}i)
|> ignore(~r{deps})
|> notification(:off) #Disabled it and using ex_unit_notifier insteadguard("elm test", run_on_start: true)
|> command("elm-test assets/tests/")
|> watch(~r{\.(elm)\z}i)
|> ignore(~r{elm-stuff})
|> notification(:auto)
```