namshi / winston-graylog2

Graylog2 transport for winston, a nodejs logging module
MIT License
126 stars 62 forks source link

Add precommit hook: run tests and lint code on each commit #64

Closed schfkt closed 6 years ago

schfkt commented 6 years ago

That way code (both tests and linting) will be checked locally on each commit. So, if you break anything, you'll immediately know. Since failing precommit hook will abort a commit. For example:

$ git commit
husky > npm run -s precommit (node v8.9.4)

 ❯ Running tasks for *.js
   ✖ npm run lint
     npm run test
✖ "npm run lint" found some errors. Please fix them and try committing again.

/home/schfkt/Documents/code/winston-graylog2/lib/winston-graylog2.js
16:5  error  Replace `'emerg'` with `emerg`               prettier/prettier
16:5  error  Unnecessarily quoted property 'emerg' found  quote-props

✖ 2 problems (2 errors, 0 warnings)
  2 errors, 0 warnings potentially fixable with the `--fix` option.

husky > pre-commit hook failed (add --no-verify to bypass)
$ git commit
husky > npm run -s precommit (node v8.9.4)

 ❯ Running tasks for *.js
   ✔ npm run lint
   ✖ npm run test
✖ "npm run test" found some errors. Please fix them and try committing again.

  winstone-graylog2
    Creating the trasport
  1) should have default properties when instantiated

  0 passing (5ms)
  1 failing

  1) winstone-graylog2
   Creating the trasport
     should have default properties when instantiated:

  AssertionError [ERR_ASSERTION]: false == true
  + expected - actual

  -false
  +true

  at Context.<anonymous> (test/winston-graylog2-test.js:12:14)

husky > pre-commit hook failed (add --no-verify to bypass)