evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.96k stars 218 forks source link

Feature request: allow disabling postinstall script which force install the hook script files #198

Open PikachuEXE opened 3 years ago

PikachuEXE commented 3 years ago

I run yarn upgrade every day Since 0.7.5 maybe due to https://github.com/evilmartians/lefthook/pull/184/files#diff-7733b4a9c49683a0e815d9a617050a5549df9945bcb92d8008cb7009f34aa19d The postinstall script is run every time (i.e. lefthook install -f) on yarn upgrade I have a customized script pre-commit (which run lefthook in an login shell) Also I don't need the script prepare-commit-msg

Currently I can't skip just lefthook's postinstall script due to https://github.com/yarnpkg/yarn/issues/7338

Background for using customized script I am using SourceTree and it won't use RVM's ruby version So I moved most code from `pre-commit` to `pre-commit-run` and replace the removed code with ```bash script_dir=$(dirname $0) bash --login -c "$script_dir/pre-commit-run $@" ```
PikachuEXE commented 3 years ago

image Installing the ruby gem would print this message. But I guess there is no post install message in npm...

Edit 1: Until fixed you can consider using CI=true yarn upgrade as workaround but might affect other packages Edit 2: I just remove the package and use ruby gem version in my Ruby on Rails project

Envek commented 3 years ago

Hey! Sorry for the late reply. We don't have a solution at the moment.

I'm just wondering whether you issue will be fixed if we will use just lefthook install without --force option in postinstall script (not sure why exactly -f is being used).

PikachuEXE commented 3 years ago

If prepare-commit-msg is installed every time when I don't need it I think it's still not expected

anthony-hayes commented 10 months ago

I was definitely taken aback by the automatic postinstall stuff, I believehusky abandoned that approach versions ago 😅 https://typicode.github.io/husky/getting-started.html you have to set it up yourself

Was hoping to have lefthook as an opt-in (using lefthook install) when using the npm package, but might have to go with another tool

mrexox commented 7 months ago

If you don't want to force developers using lefthook in your project then I believe you can just put a lefthook.yml into your repo and use a globally installed binary. But if you add lefthook into devDependencies I assume that you want it's postinstall script to do lefthook install automatically. I find it convenient and rather explicit. For the optional use you can always remove the lefthook dependency.