BitBucket is Git Management solution from Atlasian. It is free for small teams up to 5 active team members and support all Git repository features. More about Bitbucket could be fount at their website https://bitbucket.org/ .
Pre-commit hooks are powerful functionality to execute own scripts after staging git changes but before commit them to the local repository. Thanks to this solution developers are able to execute code quality checks and code tests before the code officially lands at the repository. Pre-commit hook is not the only hook supported by Git. Other common hooks are:
But the most important from code quality and test perspective are pre-commit and pre-push ones.
Husky is node js tool written by Typicode and supporters as open source support for bad git commit prevention. Project homepage is https://github.com/typicode/husky and of course https://www.npmjs.com/package/husky.
Putting all together. The goal is to perform code quality checks and test before committing them to local code repository to ensure best possible code stability.
First step like always for npm libraries and tools is installation.
npm install husky –save-dev or npm i husky
depends of Your need.
Next step is adding configuration to package.json
„pre-commit”: „npm test”,
„pre-push”: „npm test”
General approach is “name of the hook” : “script / command to be executed”.
And that’s all!
You have full support to pre-commit hook and can execute any bash script like npm test.