observing/pre-commit

Does not find correct root.

nvasilakis opened this issue · 1 comments

Hi — thanks for this package.

It turns out it does not work if the directory structure is not the one assumed by pre-commit. Specifically, it seems to assume that git root is path.resolve(__dirname, '..', '..') which might not be the case (as it happens in our setup). A safer way to get the root would be git rev-parse --show-toplevel. If folks agree, I can submit a pull request.

(A smaller, but related, problem is that the install.js script fails silently in this case — i.e., without providing any feedback on where to start from. Without any message, just the effort of understanding how pre-commit works to fix this problem might be more than the effort of just setting the pre-commit hook manually; thus, adding a short message would bring significant benefits.)

It turns out that he master branch is behind the one published on npm. I run version ^1.2.2, but when cloning to fix, I see someone has already added code that is not reflected on npm — it's still not the full solution, but it does include a nice error message.