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 150 forks source link

Only check staged files #74

Open alallier opened 8 years ago

alallier commented 8 years ago

Only check staged files when trying to commit

okonet commented 8 years ago

Not sure if this should be in scope of this library but I've created https://github.com/okonet/lint-staged for this. Check it out and let me know what you think.

alallier commented 8 years ago

Great, this is exactly what I was looking for; I didn't realize you had another repo for this. Thanks for your quick and diligent response on this!

okonet commented 8 years ago

Just FYI I'm not the maintainer nor developer of this package... just stumbled upon this issue.

alallier commented 8 years ago

Thank you I overlooked your username originally.

alallier commented 8 years ago

I'm going to re-open and wait and see what the owner has to say.

rehia commented 7 years ago

I agree that this should not be part of this library, at least as far as I understand it. But I would definitely get a property called onFailure (or something close) or preferably finally, so we can give a npm script name which would be run respectively when an error occurs or always, at the end of the pre-commit. This would help us start with a script which stash everything but staged files, and unstash those files once scripts have run, whatever the result.

okonet commented 7 years ago

Actually that would be awesome! Stashing and unstashing is something I'd like to integrate into 🚫💩 lint-staged but it's not trivial at the moment.

okonet commented 7 years ago

I'm not sure though it can be done as part of the pre-commmit hook.

bertyhell commented 3 years ago

I've created a script that does exactly this. It uses pre-commit to start a node script that programmatically goes over all the staged files.

https://gist.github.com/bertyhell/c8ae817626e053375bad0d62efc1da7d

Improvements are welcome.