husky钩子

1、介绍:这是一个git钩子,作用有可以在提交的时候去触发想调用的命令,比如代码风格格式化或者其他的命令

2、用法:https://typicode.github.io/husky/#/?id=automatic-recommended

安装

npm install husky --save-dev

初始化(官方推荐)

npx husky-init && npm install       # npm
npx husky-init && yarn              # Yarn 1
yarn dlx husky-init --yarn2 && yarn # Yarn 2+
pnpm dlx husky-init && pnpm install # pnpm

添加钩子(比如提交时触发node app.js命令)

npx husky add .husky/commit-msg 'node app.js'

卸载

npm uninstall husky && git config --unset core.hooksPath

 

posted @ 2022-07-12 14:22  Pavetr  阅读(184)  评论(0)    收藏  举报