Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 877 Bytes

node.md

File metadata and controls

40 lines (30 loc) · 877 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:

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.