sindresorhus/ama

Why don't you use git pre-push hooks?

zikaari opened this issue · 4 comments

For people who send you PR's without running npm test and realizing that after Travis CI fails.

Don't you think pre-push git hook that runs npm test for them will prevent accidental bad pushes?

👍 that wouldn't be a bad idea.

However then it wouldn't look as "clean" & simplistic as =>

  "scripts": {
    "test": "xo && ava"
  },

That's the premise actually. New contributors (even myself) sometimes forget to run npm test as said in the OP.

Too bad npm doesn't have prePush hook.

Enforcing this is as simple as:

echo 'exec npm test' > .git/hooks/pre-push
Neaox commented

Husky can help with this. (https://www.npmjs.com/package/husky)

That's a good one. Thanks for pointing that out!