[NPM] Run npm scripts with git hooks

In this lesson we will look about how we can integrate with git hooks to help enforce a certain level of quality before you either commit your code or push to a remote repository.

 

Install:

npm i -D husky

 

Add script:

For each commit:

"precommit": "npm t"

This will run before each commit.

 

For each push:

"prepush": "npm t"

This will run before each push.

 

But if for some reason, if you want bypass the precommit or prepush check, you can do:

git commit -m "commit message" --no-verify

 

posted @ 2017-02-07 21:22  Zhentiw  阅读(357)  评论(0)    收藏  举报