Skip actual `npm run`?
Opened this issue · 1 comments
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: prettier/prettier#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.
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.