toplenboren / simple-git-hooks

A simple git hooks manager for small projects
MIT License
1.34k stars 43 forks source link

When used in a dependency, the hooks installed into the parent package #82

Open jfparadis-appomni opened 2 years ago

jfparadis-appomni commented 2 years ago

I came across a package that was updating its git hooks with a post install script:

 "postinstall": "npx simple-git-hooks",

When that package was installed as a dependency of another package, it installed the hooks in the parent package.

toplenboren commented 2 years ago

Hi, thanks for the report. Gonna try to catch and fix this in spare time

zhou-tao commented 1 year ago

same problem. can resolved it now?

toplenboren commented 8 months ago

Okay, there are two problems here:


If you do not use simple-git-hooks you are going to get something like this:

npm ERR! code 127
npm ERR! path /home/.../workspace/test/node_modules/json-editor-vue
npm ERR! command failed
npm ERR! command sh -c simple-git-hooks
npm ERR! sh: line 1: simple-git-hooks: command not found

Taken from https://github.com/cloydlau/json-editor-vue/issues/73

I will not be able to fix this, since simple-git-hooks is not even executed here :(


If you have simple-git-hooks then this package will trigger install of the hooks. Will add an additional check for that case

l generally advise agains calling simple-git-hooks as a postinstall script in your own package. It should be removed upon publishing to npm.

Added a note about that in `README.md