tc39 / template-for-proposals

A template for ECMAScript proposals
MIT License
127 stars 29 forks source link

Maybe use `pre-commit` to auto install hooks #14

Closed mikesamuel closed 5 years ago

mikesamuel commented 5 years ago

https://www.npmjs.com/package/pre-commit

pre-commit is a pre-commit hook installer for git. It will ensure that your npm test (or other specified scripts) passes before you can commit your changes. This all conveniently configured in your package.json.

So if the package.json listed pre-commit as a devDependency and included

  "pre-commit": [
    "build"
  ],

you could do away with this language from the README:

  1. Add a post-rewrite git hook to auto-rebuild the output on every commit: cp hooks/post-rewrite .git/hooks/post-rewrite chmod +x .git/hooks/post-rewrite

I'm happy to send a PR your way

ljharb commented 5 years ago

I am very much against any sort of package that installs git hooks implicitly - there's a reason git doesn't function that way; I find it very unsafe.

mikesamuel commented 5 years ago

Fair enough.

ljharb commented 5 years ago

(To be clear, thank you for the suggestion, and if there's a way to make it easier to install the hook explicitly i'm all for that)

mikesamuel commented 5 years ago

That's a legitimate concern. Other ecosystems have had serious breaches due to dodgy hooks.

For small, personal projects where I'm the only committer, I'm more worried about checking out a fresh client and missing something.