Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 820 Bytes

node.md

File metadata and controls

37 lines (28 loc) · 820 Bytes

Lefthook in Node.js

This is guide of using Lefthook git hook manager in Node.js projects. You can find guides for other environments in README.md.

Install

Lefthook is available on npm and can be installed with:

npm install @arkweid/lefthook --save-dev

Edit

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}

Test it

npx lefthook install && npx lefthook run pre-commit

More info

Have a question? Check the wiki.