husky
9.1.7 · 18 Nov 2024MIT49.9M / weekRepositoryHomepagenpmAtom feed
157 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 9.x · latest line
9.1.7
18 Nov 2024Add husky label to deprecated warning
9.1.6
11 Sep 2024Fix issue where example pre-commit file is generated incorrectly
9.1.4
29 Jul 2024Improve deprecation notice
9.1.3
26 Jul 2024Better handle space in
PATH
9.1.2
25 Jul 2024Show a message instead of automatically removing deprecated code.
Show a message instead of automatically removing deprecated code.
This only concerns projects that still have the following code in their hooks:
- #!/usr/bin/env sh # <- This is deprecated, remove it - . "$(dirname -- "$0")/_/husky.sh" # <- This is deprecated, remove it # Rest of your hook code
Hooks with these lines will fail in
v10.0.09.1.1
18 Jul 2024- deprecated
#!/usr/bin/env shand. "$(dirname -- "$0")/_/husky.sh"are deprecated.huskycommand will automatically remove them, no action required. - deprecated
If you're having code in
~/.huskyrcplease move it to.config/husky/init.sh bunx husky initcommand
Super saiyan
goddog! It's over 9.0.0!What's new
You can now run package commands directly, no need for
npxor equivalents.
It makes writing hooks more intuitive and is also slightly faster 🐺⚡️# .husky/pre-commit - npx jest + jest # ~0.2s faster
A new recipe has been added to the docs. Lint staged files without external dependencies (inspired by Prettier docs). Feel free to modify it.
# .husky/pre-commit prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown git update-index --again
For more advanced use cases, see lint-staged.
Fixes
bunx husky initcommandWorkaround for some hooks implementation on Windows
Deprecations
- deprecated
#!/usr/bin/env shand. "$(dirname -- "$0")/_/husky.sh"are deprecated.huskycommand will automatically remove them, no action required. - deprecated
If you're having code in
~/.huskyrcplease move it to.config/husky/init.sh
Support for these will be removed in v10.
Friendly reminder
If Git hooks don't fit your workflow, you can disable Husky globally. Just add
export HUSKY=0to.config/husky/init.sh.I've seen some confusion about this on X, so just a heads-up!
Sponsoring
Husky is downloaded over 45M times per month and used by ~1.5M projects. If your company wants to sponsor, you can do so here: GitHub Sponsors.
Have a nice summer ☀️ I'm open to new opportunities/consulting so feel free to drop me a message 😉
9.1.0
17 Jul 20249.0.10
1 Feb 2024Rename index.d.ts to index.d.mts
9.0.9
1 Feb 2024Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
9.0.8
1 Feb 2024Fix tab detection on install command
Fix tab detection on install command
9.0.7
29 Jan 2024Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
9.0.6
25 Jan 2024Fix unbound variable
Fix unbound variable
9.0.5
25 Jan 2024Init error
Init error
9.0.3
25 Jan 2024Add scripts field if not present
Insert final newline
Fix git hooks path on windows
Add scripts field if not present
Insert final newline
Fix git hooks path on windows
9.0.2
25 Jan 2024Exit code
Exit code
9.0.1
25 Jan 2024- removed
Dropped support for Node 14 and 16.
Enhanced security with CI and npm
--provenancefor safer publishing.Added
$XDG_CONFIG_HOMEsupport. Move~/.huskyrcto~/.config/husky/init.shfor centralized configuration.
Kicking off the year with an exciting update!
Note: install using
husky@latestto get the bug fixes that were released after.Introducing
husky initv8
npm pkg set scripts.prepare="husky install" npm run prepare npx husky add .husky/pre-commit "npm test"
v9
Adding husky to a project is now easier than ever. It's just a single line that does the same as above. No need to read the docs to get started anymore.
npx husky init
Adding a New Hook
v8
npx husky add .husky/pre-commit "npm test" git add --chmod=+x .husky/pre-commit # On Windows
v9
Adding a hook is as simple as creating a file. This can be accomplished using your favorite editor, a script or a basic
echocommand. For example, on Linux/macOS:echo "npm test" > .husky/pre-commit
Further Size Reduction
v8was already the most compact Git hooks manager at approximately6kB.v9takes this a step further, reducing the size to just3kB, likely making it the smallest devDependency in your toolkit.To give you an idea of how small it is, the biggest file in the project is the MIT license 😄
More to Come
Additional features are in the pipeline for
v9. Stay tuned :raised_hands:Other Changes
Enhanced security with CI and npm
--provenancefor safer publishing.Added
$XDG_CONFIG_HOMEsupport. Move~/.huskyrcto~/.config/husky/init.shfor centralized configuration.Fixed permission issue for Windows-created hooks; they no longer need to be executable.
Removed
husky install. Usehuskyorhusky some/dirfor the same functionality (deprecation notice to be added).Modified behavior when
.gitis missing; it now triggers a warning instead of failure.Replaced
HUSKY_DEBUG=1withHUSKY=2for debugging.Updated the Husky API for module usage.
Transitioned to
ESMfor module usage.- removed
Dropped support for Node 14 and 16.
Revamped docs.
How to Migrate
v9is backward compatible withv8, allowing you to freely upgrade and migrate your hooks later.Here are the steps to migrate:
package.json{ "scripts": { - "prepare": "husky install" + "prepare": "husky" } }.husky/pre-commit- #!/usr/bin/env sh - . "$(dirname -- "$0")/_/husky.sh" npm test
Note:
shwill be used to run hooks, even if a shebang is set.If you were using
huskyas a module:- const husky = require('husky') - // ... + import husky from 'husky' + console.log(husky())- 8.x
8.0.2
8 Nov 2022Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
8.0.1
9 May 2022Use POSIX equality operator
8.0.0
8 May 2022- removed
Drop Node 12 support
Add
husky -prefix to logged global error messagesShow
PATHwhen command not found to improve debuggability
What's Changed
Feats
Add
husky -prefix to logged global error messagesShow
PATHwhen command not found to improve debuggability- removed
Drop Node 12 support
Skip install if
$HUSKY=0
Fixes
Hook script use
/usr/bin/env shinstead of direct path ofshActually set 'husky_skip_init' as readonly in
./husky.shForce
basename/dirnameto treat$0as an argumentRemove
git.iolinks
- 7.x
7.0.4
21 Oct 2021No changes. Husky v7.0.3 was reverted, this version is the same as v7.0.2.
7.0.3
21 Oct 20217.0.0
1 Jul 2021- removed
Drop Node 10 support
Improve
.husky/directory structure..husky/.gitignoreis now unnecessary and can be removed.Improve error output (shorter)
Improve
.husky/directory structure..husky/.gitignoreis now unnecessary and can be removed.Improve error output (shorter)
Update
husky-initCLIUpdate
husky-4-to-7CLI- removed
Drop Node 10 support
Please help me develop and release OSS projects :heart: on GitHub Sponsors or Open Collective. Thank you for your support!
- 6.x
6.0.0
29 Mar 2021- breaking
husky inithas been moved to its own package (npx husky-init) Programmatically use husky:
require('husky')TypeScript definitions
After being in early access for Open Source projects and Sponsors for a limited time, I'm happy to announce that husky 6 is MIT again and can be freely used in commercial projects! 🎉
Many thanks to the Open Source projects and Companies which have switched to/sponsored the new husky during this period!
OSS is my full-time job, please consider sponsoring the development of husky on GitHub sponsors or Open Collective. Thank you!
Breaking change
- breaking
husky inithas been moved to its own package (npx husky-init)
Added
Programmatically use husky:
require('husky')TypeScript definitions
Migrating from husky 4
Husky 6 contains breaking changes. If you're coming from v4,
npm install husky@6won't be enough.Recommended: see husky-4-to-6 CLI to automatically migrate your config. There's also a dedicated section in the docs.
If you're curious why config has changed, you may be interested in reading:
blog.typicode.com/husky-git-hooks-javascript-co…Also Husky 6 follows official npm and Yarn best practices regarding autoinstall. It's recommended to use
preparescript instead (see usage in docs).- 5.x
5.2.0
21 Mar 2021Add
setcommand to replace hooks (husky set .husky/pre-commit cmd)Update
addcommand to append command (husky add .husky/pre-commit cmd)Improve error messages
5.1.3
2 Mar 2021cli:
husky initwill detect Yarn v2 and initialize accordingly
cli:
husky initwill detect Yarn v2 and initialize accordingly
5.1.2
1 Mar 2021cli:
husky initusepreparescript
cli:
husky initusepreparescript
5.1.1
22 Feb 2021init: Update package.json postinstall
init: Update package.json postinstall
5.1.0
21 Feb 2021Add
husky init
5.0.9
8 Feb 2021install: Do not fail if not inside a Git directory (closes #851)
install: Do not fail if not inside a Git directory (closes #851)
See github.com/typicode/husky/releases/tag/v5.0.0 for v5 release notes
5.0.7
27 Jan 2021shell: Double quote params
5.0.6
11 Dec 2020Remove unused files
5.0.0
16 Nov 2020👉 See typicode.github.io/husky for breaking changes and new installation instructions.
👉 See typicode.github.io/husky for breaking changes and new installation instructions.
Note about the license
Husky 5 is released under The Parity Public License.
It doesn't affect you if you're using husky in an Open Source project or if you're a sponsor. You're free to use it as usual and I hope you'll enjoy this new release ❤️
If you're using husky in a commercial project, you may want to consider becoming a sponsor to support the project. You can also try it for 30 days.
This is only for a limited time, husky will be MIT again later.
Migrating
Important Husky v5 brings a lot of improvements but is also very different from v4. Git hooks won't work if you only upgrade husky dependency, existing config needs to be migrated too.
The best way to switch to v5 is to follow the new installation instructions and migrate existing hooks command using
husky add.- 4.x
4.3.8
15 Jan 2021Fix
Cannot read property 'toString' of nullImprove error messages
4.3.5
7 Dec 2020Rollback and do not throw error if husky install fails
4.3.4
5 Dec 2020Throw error if husky install fails
Add workaround for npm 7 currently missing
INIT_CWDenvironment variable
4.3.3
5 Dec 2020