# `Juggernaut.Watch`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/watch.ex#L1)

`--watch` (design notes §12): polls the modification times and sizes of the files under
`paths`, `test_paths` and `config/` every 500 ms (no file-system dependency), waits until
a change has been still for 300 ms, then asks the server for an inner-lane run of what
changed (`mix juggernaut --lane inner`: the clauses changed since `base`, uncommitted
work included).

`snapshot/2` and `changes/2` are pure over the file system's answers; `loop/2` drives
them until interrupted (or, for tests, `:runs` runs).

# `snapshot`

```elixir
@type snapshot() :: %{required(String.t()) =&gt; {integer(), non_neg_integer()}}
```

Path to `{mtime, size}`.

# `changes`

```elixir
@spec changes(snapshot(), snapshot()) :: [String.t()]
```

The files added, changed or removed between two snapshots, sorted.

# `dirs`

```elixir
@spec dirs(%{paths: [String.t()], test_paths: :project | [String.t()]}) :: [
  String.t()
]
```

The directories a watch covers for `config`.

# `loop`

```elixir
@spec loop(Path.t(), keyword(), ([String.t()] -&gt; term())) :: :ok
```

Watches `root`: on each settled change calls `on_change` with the changed files.
Options: `:dirs` (required), `:runs` (stop after this many, default never),
`:poll_ms` (500), `:debounce_ms` (300), `:notify` (called with the snapshot once
watching has begun, for tests). Returns `:ok` after `:runs` changes.

# `snapshot`

```elixir
@spec snapshot(Path.t(), [String.t()]) :: snapshot()
```

The files under `dirs` (relative to `root`, missing ones skipped) and their stamps.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
