Watching
For tasks whose source files change frequently and should re-run on every change.
Tasks with source folders and files can be watched and restarted when they change. This is useful, for example, to run API servers that restart when the server code changes.
tasks:
api:
src:
- src
cmds:
- node -r ts-node/register src/index.tshammerkit api --watchIn watch mode hammerkit watches the src of every task in the run. When a file
changes it re-runs the affected task — and, because it knows the dependency graph,
any tasks downstream of it — reusing cached results for everything unchanged. A
short debounce coalesces bursts of saves into a single restart. Combine --watch
with services (via needs, or hammerkit up --watch) to keep a
database running while your api restarts on every edit; the
development workflow guide puts these together.
Tools that watch their files
Some tools watch their files themselves and rebuild incrementally, which is faster than
hammerkit restarting them: ng serve, vite, nodemon. They run until you stop
them, so they are a service with continuous: true,
not a task. hammerkit up --watch starts them once and leaves them running while their
files change.
services:
serve:
image: node:24
continuous: true
src:
- src
- angular.json
cmd: npx ng serve --host 0.0.0.0
ports:
- 4200Before hammerkit 2, a task could be marked continuous too. Such a build file now fails to
parse: make the task a service, with its cmds as its cmd.