This is guide of using Lefthook git hook manager in Node.js projects. You can find guides for other environments in README.md.
Lefthook is available on npm and can be installed with:
npm install @arkweid/lefthook --save-dev
Edit lefthook.yml
:
pre-commit:
parallel: true
commands:
linter:
files: git diff --name-only @{push}
glob: "*.{js,ts}"
run: npx eslint {files}
tests:
files: git diff --name-only @{push}
glob: "*.{js,ts}"
run: jest --findRelatedTests {files}
npx lefthook install && npx lefthook run pre-commit
Have a question? Check the wiki.