You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add pre/post lifecycle hooks for package.json scripts (#231)
## Summary
Adds npm-style pre/post lifecycle hooks for package.json scripts.
If you have a script named `test`, you can now define `pretest` and
`posttest` scripts that automatically run before and after it — no extra
configuration needed:
```json
{
"scripts": {
"pretest": "docker compose up -d",
"test": "vitest run",
"posttest": "docker compose down"
}
}
```
Running `vt run test` will execute all three in order.
### Behavior
- Hooks apply only to package.json scripts, not tasks defined in
`vite-task.json`
- Extra CLI args (e.g. `vt run test --coverage`) are passed to the main
script only, not the hooks
- Hooks are one level deep: when `test` runs `pretest` as a hook,
`pretest` does not also run `prepretest` — matching npm's behavior
- Opt out workspace-wide with `enablePrePostScripts: false` in the root
`vite-task.json`
## Test plan
- [ ] `script-hooks`: pre/post hooks run in correct order; extra args
not forwarded to hooks; running `pretest` directly does expand
`prepretest`, but `prepretest` is not included when `pretest` runs as a
hook of `test`
- [ ] `script-hooks-disabled`: `enablePrePostScripts: false` suppresses
hooks
- [ ] `script-hooks-task-no-hook`: task configs are not expanded with
hooks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments