simple-git-hooks
simple-git-hooks copied to clipboard
[Question] run npx simple-git-hooks every time you change a command
Is this a good idea to do something like this?
"simple-git-hooks": {
"pre-commit": "npx simple-git-hooks && npx lint-staged"
}
so that people don't need to run npx simple-git-hooks
command when the config change
This shouldn't break things :) Gonna try it tomorrow, if this solution doesnt affect performance and works well, then gonna add it to the docs
Thanks for the idea!
Couldn't this be done internally, before each command is run?
Check the hash and/or file modification time of the package.json or configuration file, and if it has changed, re-run setup?
Another idea: Install a post-merge
hook that checks for updates to configuration, and if necessary, re-runs setup.
Definitely a fan of automatically keeping this synced as well! If a package updates a hooks' command, consumers' hooks should be updated without manual work of their own.
Thanks for the library, toplenboren!
Also, what about initial hooks install? For example, if I'll replace husky with simple-git-hooks in my project, I need to say all project members to run npx simple-git-hooks
. Doesn't seem nice to me.
@Djaler Is that not handled by the postinstall
script?
Hmm, looks like yes. I just didn't see this in readme
Can someone confirm that the post-merge
"auto-updating" of hooks work? It's the only thing holding me back from migrating/fleeing from husky@4
@JaneJeon It hasn't been implemented, as far as I know.
@glen-84 sorry, I didn’t mean if that feature was “built-in” to this library, but rather whether it was possible to get the husky-like functionality by just prepending a npx simple-git-hooks
to the post-merge
hook.
@JaneJeon Oh I see. I haven't tried it yet, TBH. 🙂
You may not need npx, you can also do simple-git-hooks
as script after npm i simple-git-hooks --save-dev
, that you can add to the prepare
script in your package.json.
I am using this:
"prepare": "is-ci || npx simple-git-hooks"
https://www.npmjs.com/package/is-ci