observing / pre-commit

Automatically installs a git pre-commit script in your git repository which runs your `npm test` on pre-commit
MIT License
1.88k stars 152 forks source link

Skip actual `npm run`? #93

Open rauchg opened 7 years ago

rauchg commented 7 years ago

I love the fact that pre-commit ties directly into package.json scripts from an ergonomics perspective.

However, I think it'd be a good idea to avoid the npm sub-process altogether, for performance reasons. You could, for example, look up the scripts yourself and run them with the ./node_modules/.bin prefix.

Every commit will pay a penalty of ~380ms per pre-commit script defined. See investigation by @vjeux: https://github.com/jlongster/prettier/issues/443

Since pre-commit is now the recommended way to set up prettier, I think this is very much a worthwhile optimization that'll save a lot of time to many people.

3rd-Eden commented 7 years ago

The reason that I hooked into the npm process is because npm introduces a bunch of environment variables and what not when it starts a script. I honestly don't know if this is something that a lot people are using, but I'm all for removing this extra step.