Juggernaut.Watch (Juggernaut v0.4.0)

Copy Markdown View Source

--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).

Summary

Types

Path to {mtime, size}.

Functions

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

The directories a watch covers for config.

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.

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

Types

snapshot()

@type snapshot() :: %{required(String.t()) => {integer(), non_neg_integer()}}

Path to {mtime, size}.

Functions

changes(old, new)

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

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

dirs(config)

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

The directories a watch covers for config.

loop(root, opts, on_change)

@spec loop(Path.t(), keyword(), ([String.t()] -> 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(root, dirs)

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

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