29 lines
527 B
Plaintext
29 lines
527 B
Plaintext
1.Initialize a Git repository
|
|
git init
|
|
|
|
2.Install Husky as a development dependency:
|
|
npm install husky --save-dev
|
|
|
|
3.Enable Husky in your project:
|
|
npx husky install
|
|
|
|
4.Add the following script to your package.json to automatically install Husky hooks after installing dependencies:
|
|
|
|
{
|
|
"scripts": {
|
|
"prepare": "husky install"
|
|
}
|
|
}
|
|
|
|
5.Add a pre-commit hook:
|
|
npx husky add .husky/pre-commit "npm test"
|
|
|
|
Pre-commit file
|
|
#!/bin/sh
|
|
. "$(dirname "$0")/_/husky.sh"
|
|
|
|
npm test
|
|
|
|
6.Customize pre-commit
|
|
|
|
7.Customize package.json |