Repository navigation
Releases
v0.3.0
Bun and Deno: Ward now installs and runs hooks on Node, Bun and Deno, with the same config.
Warning
Ward is in early development (0.x). Until 1.0, any minor release may change the config and behavior.
Install
# npm
npm install -D @hexlabelposition/ward
npm pkg set scripts.prepare=ward
npm run prepare
# Bun: the same "prepare": "ward" script, run by bun install
bun add -d @hexlabelposition/ward
# Deno: add "prepare": "deno run -A npm:@hexlabelposition/ward" to deno.json tasks
deno add npm:@hexlabelposition/ward
deno task preparePublished with npm provenance. Requires Git 2.20 or later and Node.js 24 or later, Bun or Deno 2. Two runtime dependencies (yaml, picomatch), ESM-only.
What's in v0.3
Bun
bun installrunsprepareand installs the hooks, also from a workspace package.- Stubs start Ward on the runtime that ran the install: Node when it is installed, Bun when it is not.
ward.config.tsaccepts full TypeScript syntax (enum,namespace, parameter properties), and syntax errors point at the line.
Deno
- Install from a
deno.jsontask:deno task prepare. Deno has nopreparelifecycle, so run it after cloning and after updating Ward. - Hooks run
deno run -A npm:@hexlabelposition/ward, at the version fromdeno.jsonorpackage.jsonand the lockfile. Nonode_modulesis needed. ward.config.tsaccepts full TypeScript syntax, and syntax errors point at the line.
All runtimes
WARD_RUNTIME=node,bunordenooverrides the runtime of the stubs for one command:WARD_RUNTIME=node git commit. An unknown value or a runtime that is not installed fails the hook with a hint.- Install hints show the command for the runtime in use (
npx ward,bunx ward,deno run -A npm:@hexlabelposition/ward). - On Windows, the binary Bun writes for a workspace package (
ward.exe) is found.
Tested on
Ubuntu, macOS and Windows, on Node.js 24 and the current release, the latest Bun and Deno 2.x. The full test suite runs on every runtime.
What's next
- v0.4: the same config in CI (
--from-ref,--all-files,--ci) and shared configs withextends. - v0.5:
ward init, and hooks without tasks that exit without starting a runtime.
See BACKLOG.md.
Full Changelog: v0.2.0...v0.3.0
v0.2.0
Tasks on staged files: Ward now replaces lint-staged as well as husky, with one config for both.
Warning
Ward is in early development (0.x). Until 1.0, any minor release may change the config and behavior.
Install
npm install -D @hexlabelposition/ward
npm pkg set scripts.prepare=ward
npm run preparePublished with npm provenance. Requires Node.js 24 or later. Two runtime dependencies (yaml, picomatch), ESM-only.
What's in v0.2
Tasks on files
- Named tasks:
{ tasks: { name: { run } } }, run in the order they are listed. {staged_files},{push_files}and{all_files}placeholders. Long file lists are split into several runs, so they fit the command line limit on Windows.globandexcludeper task pick the files a task runs on. A task with no matching files is skipped.- Files fixed by a task are staged again;
stageFixed: falseleaves them unstaged. - Symlinks are left out of file lists;
symlinks: truepasses them to the task. - Function tasks in
ward.config.ts: a function that gets the file list. parallel: trueruns the tasks of a hook at the same time, with each line of output prefixed by the task name.
Safety
- A backup with
git stash createbefore every run;backup: falseor--no-backupskips it. - Partial staging: unstaged changes of partially staged files are hidden while tasks run and put back afterwards.
- When a task fails, the index and working tree are reverted to the backup;
revert: falseor--no-revertkeeps the changes of the tasks. - Deletions, binary files, renames, symlinks and merge conflicts are handled in the backup and partial staging.
- A
pre-commitwhose tasks undid every staged change fails instead of making an empty commit.
Install
ward --bin <path>sets the binary the hooks call instead ofnode_modules/.bin/ward.
Moving from lint-staged
Move each glob and its commands into a named task with glob and {staged_files}, then remove lint-staged. See Moving from lint-staged.
Tested on
Ubuntu, macOS and Windows, on Node.js 24 and the current release.
What's next
- v0.3: Bun and Deno.
- v0.4: the same config in CI (
--from-ref,--all-files,--ci) and shared configs withextends.
See BACKLOG.md.
Full Changelog: v0.1.0...v0.2.0
v0.1.0
First release of Ward: git hooks from one config file, with no hook folder in your repo. This version replaces husky.
Warning
Ward is in early development (0.x). Until 1.0, any minor release may change the config and behavior.
Install
npm install -D @hexlabelposition/ward
npm pkg set scripts.prepare=ward
npm run preparePublished with npm provenance. Requires Node.js 24 or later. One runtime dependency (yaml), ESM-only.
What's in v0.1
Config
- One config for all hooks:
ward.config.ts,ward.yml/ward.yaml, or a"ward"section inpackage.json. Finding more than one is an error, not a silent pick. defineConfig()gives types and autocomplete; the TS config is loaded by Node's built-in type stripping, with no loader dependency.- A hook is a command, a list of commands, or named tasks:
"cmd",["a", "b"],{ tasks: { name: { run: "cmd" } } }. - The whole config is checked on every run. Every problem is listed with its place in the config, and typos get a suggestion:
hooks.pre-comit: unknown hook. Did you mean "pre-commit"? - Options from later versions (
glob,parallel, …) fail as "not supported yet" instead of being ignored.
Install
ward, run fromprepare, writes a small stub for every git hook into.git/hooks. Only the config is committed.- The config is read at run time, so changes apply on the next git command, with no reinstall.
- Existing hooks are never overwritten silently: Ward asks in a terminal and warns from
prepare.--chainkeeps them and runs them before Ward,--forcereplaces them. core.hooksPathis detected and reported with the command that fixes it;--respect-hooks-pathinstalls there instead.- Install does nothing in CI, outside a git repository and without git, so
npm installdoes not fail. ward uninstallremoves only Ward's stubs and puts chained hooks back.
Run
- Tasks run in order through the system shell from the repo root. The first failure stops the hook, and git gets its exit code.
{1},{2}, … expand to the arguments git passed to the hook:commitlint --edit {1}.- A hook with no tasks exits right away.
WARD=0skips Ward for one command; hooks are skipped automatically during a merge or rebase.
Moving from husky
Move the commands from .husky/* into the config, delete the folder and run git config --unset core.hooksPath. See Moving from husky.
Tested on
Ubuntu, macOS and Windows, on Node.js 24 and the current release.
What's next
- v0.2: replace lint-staged: tasks on staged files with
globand{staged_files}, safe partial staging, parallel tasks. - v0.3: Bun and Deno.
See BACKLOG.md.
Full Changelog: https://github.com/hexlabelposition/ward/commits/v0.1.0