Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] run npx simple-git-hooks every time you change a command #34

Open
pustovalov opened this issue Mar 18, 2021 · 12 comments
Open
Labels
question Further information is requested

Comments

@pustovalov
Copy link
Contributor

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

@toplenboren
Copy link
Owner

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!

@glen-84
Copy link

glen-84 commented Mar 22, 2021

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.

@JonKrone
Copy link

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!

@Djaler
Copy link
Contributor

Djaler commented Mar 24, 2021

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.

@glen-84
Copy link

glen-84 commented Mar 24, 2021

@Djaler Is that not handled by the postinstall script?

@Djaler
Copy link
Contributor

Djaler commented Mar 24, 2021

Hmm, looks like yes. I just didn't see this in readme

@JaneJeon
Copy link

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

@glen-84
Copy link

glen-84 commented Apr 13, 2021

@JaneJeon It hasn't been implemented, as far as I know.

@JaneJeon
Copy link

@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.

@glen-84
Copy link

glen-84 commented Apr 13, 2021

@JaneJeon Oh I see. I haven't tried it yet, TBH. 🙂

@DanielRuf
Copy link

DanielRuf commented Jul 20, 2021

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.

@peschee
Copy link

peschee commented Feb 15, 2022

I am using this:

"prepare": "is-ci || npx simple-git-hooks"

https://www.npmjs.com/package/is-ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants