{"id":25644504,"url":"https://github.com/stacksjs/bun-git-hooks","last_synced_at":"2025-04-15T09:14:21.250Z","repository":{"id":277232645,"uuid":"930583243","full_name":"stacksjs/bun-git-hooks","owner":"stacksjs","description":"🪝 Think of `simple-git-hooks` but optimized for all-sized Bun projects.","archived":false,"fork":false,"pushed_at":"2025-04-14T14:56:10.000Z","size":525,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T09:13:59.333Z","etag":null,"topics":["bun","cli","git","git-hooks","hook","hooks-manager","library","pre-commit","pre-push","simple-git-hooks","typescript"],"latest_commit_sha":null,"homepage":"https://bun-git-hooks.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacksjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["stacksjs","chrisbbreuer"],"open_collective":"stacksjs"}},"created_at":"2025-02-10T21:41:43.000Z","updated_at":"2025-04-11T23:24:36.000Z","dependencies_parsed_at":"2025-03-24T01:31:53.772Z","dependency_job_id":"615bd75f-aee9-4219-a139-f10b1290cdfd","html_url":"https://github.com/stacksjs/bun-git-hooks","commit_stats":null,"previous_names":["stacksjs/bun-git-hooks"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fbun-git-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fbun-git-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fbun-git-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fbun-git-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacksjs","download_url":"https://codeload.github.com/stacksjs/bun-git-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249040142,"owners_count":21202826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","cli","git","git-hooks","hook","hooks-manager","library","pre-commit","pre-push","simple-git-hooks","typescript"],"created_at":"2025-02-23T08:18:06.379Z","updated_at":"2025-04-15T09:14:21.230Z","avatar_url":"https://github.com/stacksjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stacksjs","https://github.com/sponsors/chrisbbreuer","https://opencollective.com/stacksjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\".github/art/cover.jpg\" alt=\"Social Card of this repo\"\u003e\u003c/p\u003e\n\n[![npm version][npm-version-src]][npm-version-href]\n[![GitHub Actions][github-actions-src]][github-actions-href]\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\u003c!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] --\u003e\n\u003c!-- [![Codecov][codecov-src]][codecov-href] --\u003e\n\n# bun-git-hooks\n\n\u003e A Bun-optimized TypeScript library for managing Git hooks with a robust set of configuration options.\n\n## Features\n\n- 🎯 **Simple Configuration**: Easy setup through multiple config file formats\n- 🔄 **Automatic Installation**: Hooks are installed on package installation\n- 🛡️ **Type Safe**: Written in TypeScript with comprehensive type definitions\n- 🔧 **Flexible Config**: Supports `.ts`, `.js`, `.mjs`, `.json` configurations\n- 💪 **Robust**: Handles complex Git workspace configurations\n- 🚫 **Skip Option**: Environment variable to skip hook installation\n- 🧹 **Cleanup**: Optional cleanup of unused hooks\n- 📦 **Zero Dependencies**: Minimal footprint\n- ⚡ **Fast**: Built for Bun with performance in mind\n- 🔍 **Verbose Mode**: Detailed logging for troubleshooting\n\n## Installation\n\n```bash\nbun add -D bun-git-hooks\n```\n\n## Usage\n\n### Basic Configuration\n\nCreate a `git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` _(`git-hooks.ts` works too)_ file in your project root:\n\n```ts\n// git-hooks.config.ts\nimport type { GitHooksConfig } from 'bun-git-hooks'\n\nconst config: GitHooksConfig = {\n  'pre-commit': 'bun run lint \u0026\u0026 bun run test',\n  'commit-msg': 'bun commitlint --edit $1',\n  'pre-push': 'bun run build',\n  'verbose': true,\n}\n\nexport default config\n```\n\n### JSON Configuration\n\n```json\n{\n  \"git-hooks\": {\n    \"pre-commit\": \"bun run lint \u0026\u0026 bun run test\",\n    \"commit-msg\": \"bun commitlint --edit $1\",\n    \"pre-push\": \"bun run build\"\n  }\n}\n```\n\n### CLI Usage\n\n```bash\n# Install hooks from config\ngit-hooks\n\n# alternatively, trigger the CLI with bunx\nbunx git-hooks\nbunx bun-git-hooks\n\n# Use specific config file\ngit-hooks ./custom-config.ts\n\n# Remove all hooks\ngit-hooks uninstall\n\n# Enable verbose logging\ngit-hooks --verbose\n```\n\n### Environment Variables\n\nSkip hook installation when needed:\n\n```bash\n# Skip hook installation\nSKIP_INSTALL_GIT_HOOKS=1 bun install\n\n# Skip hook execution\nSKIP_BUN_GIT_HOOKS=1 git commit -m \"skipping hooks\"\n\n# Set custom environment for hooks\nBUN_GIT_HOOKS_RC=/path/to/env git-hooks\n```\n\n### Advanced Configuration\n\n```ts\nexport default {\n  // Hook commands\n  'pre-commit': 'bun run lint \u0026\u0026 bun run test',\n  'commit-msg': 'bun commitlint --edit $1',\n\n  // Preserve specific unused hooks\n  'preserveUnused': ['post-merge', 'post-checkout'],\n\n  // Configure multiple hooks\n  'pre-push': [\n    'bun run build',\n    'bun run test:e2e'\n  ].join(' \u0026\u0026 ')\n}\n```\n\n### Error Handling\n\nThe library provides clear error messages:\n\n```ts\ntry {\n  await setHooksFromConfig()\n}\ncatch (err) {\n  if (err.message.includes('Config was not found')) {\n    console.error('Missing configuration file')\n  }\n  else if (err.message.includes('git root')) {\n    console.error('Not a Git repository')\n  }\n}\n```\n\n### TypeScript Support\n\nFull TypeScript support with detailed type definitions:\n\n```ts\ninterface GitHooksConfig {\n  'pre-commit'?: string\n  'pre-push'?: string\n  'commit-msg'?: string\n  'post-merge'?: string\n  // ... other git hooks\n  'preserveUnused'?: Array\u003cstring\u003e | boolean\n}\n\n// Types are automatically inferred\nconst config: GitHooksConfig = {\n  'pre-commit': 'bun run test',\n  'preserveUnused': ['post-checkout']\n}\n```\n\n## Testing\n\n```bash\nbun test\n```\n\n## Changelog\n\nPlease see our [releases](https://github.com/stackjs/bun-git-hooks/releases) page for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Community\n\nFor help, discussion about best practices, or any other conversation that would benefit from being searchable:\n\n[Discussions on GitHub](https://github.com/stacksjs/bun-git-hooks/discussions)\n\nFor casual chit-chat with others using this package:\n\n[Join the Stacks Discord Server](https://discord.gg/stacksjs)\n\n## Postcardware\n\n“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where `bun-git-hooks` is being used! We showcase them on our website too.\n\nOur address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎\n\n## Credits\n\nMany thanks to [`simple-git-hooks`](https://github.com/toplenboren/simple-git-hooks) and its contributors for inspiring this project.\n\n## Sponsors\n\nWe would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.\n\n- [JetBrains](https://www.jetbrains.com/)\n- [The Solana Foundation](https://solana.com/)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.\n\nMade with 💙\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/bun-git-hooks?style=flat-square\n[npm-version-href]: https://npmjs.com/package/bun-git-hooks\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/bun-git-hooks/ci.yml?style=flat-square\u0026branch=main\n[github-actions-href]: https://github.com/stacksjs/bun-git-hooks/actions?query=workflow%3Aci\n\n\u003c!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/bun-git-hooks/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/stacksjs/bun-git-hooks --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fbun-git-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacksjs%2Fbun-git-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fbun-git-hooks/lists"}