← 返回命令列表

Linux command

husky 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Initialize husky

npx husky init

Add pre-commit hook

npx husky add .husky/pre-commit "npm test"

Install hooks

npx husky install

Set hook

npx husky set .husky/pre-push "npm run lint"

说明

Husky improves Git hooks management for JavaScript projects. It enables running linters, tests, and other scripts on commit and push. The tool simplifies hook configuration in package.json. It's widely used with lint-staged for pre-commit code quality checks.

参数

init
Initialize husky.
install
Install git hooks.
add _FILE_ _CMD_
Add hook script.
set _FILE_ _CMD_
Set hook content.
--help
Display help information.

FAQ

What is the husky command used for?

Husky improves Git hooks management for JavaScript projects. It enables running linters, tests, and other scripts on commit and push. The tool simplifies hook configuration in package.json. It's widely used with lint-staged for pre-commit code quality checks.

How do I run a basic husky example?

Run `npx husky init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does init do in husky?

Initialize husky.