mirror of
https://github.com/hanzoai/husky.git
synced 2026-09-24 16:59:45 +00:00
1.4 KiB
1.4 KiB
Migrate from v4
If you were calling package.json scripts using npm or yarn, you can simply copy your commands from your config file to the corresponding hook:
Husky v4
// package.json
{
"hooks": {
"pre-commit": "npm test && npm run foo" // [!code hl]
}
}
Husky v9
# .husky/pre-commit
# Note that you can now have commands on multiple lines
npm test // [!code hl]
npm run foo // [!code hl]
If you were calling locally installed binaries, you need to run them via your package manager now:
::: code-group
{
"hooks": {
"pre-commit": "jest"
}
}
# ...
npx --no jest
# or
yarn jest
:::
HUSKY_GIT_PARAMS environment variable is replaced now by native params $1, $2, etc.
::: code-group
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
# ...
npx --no -- commitlint --edit $1
# or
yarn commitlint --edit $1
:::
Other environment variables changes:
HUSKY_SKIP_HOOKSis replaced byHUSKY.HUSKY_SKIP_INSTALLis replaced byHUSKY.HUSKY_GIT_PARAMSis removed. Instead Git parameters should be used directly in scripts (e.g.$1).PATHfor locally installed tools is not automatically set anymore. You'll need to use your package manager to run them.