Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

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:

npm install @arkweid/lefthook --save-dev
# or yarn:
yarn add -D @arkweid/lefthook

Edit

Edit lefthook.yml:

pre-commit:
  parallel: true
  commands:
    linter:
      files: git diff --name-only @{push}
      glob: "*.{js,ts,jsx,tsx}"
      run: npx eslint {files}
    tests:
      files: git diff --name-only @{push}
      glob: "*.{js,ts, jsx, tsx}"
      run: jest --findRelatedTests {files}

Test it

npx @arkweid/lefthook install && npx @arkweid/lefthook run pre-commit

More info

Have a question? Check the wiki.