Fix path for searching npm-installed binary when in worktree #193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #192
The problem arises when:
package.json
is different from version in the current worktreeThen previously used code always return path to main worktree and founds old Lefthook binary there.
Current code will return path to the root of currently used worktree.
In most cases plain
pwd -P
would be enough but docs for git hooks states that:While Lefthook is always used in non-bare repositories, there is still chance that someone would like to use mentioned hooks that triggered during push, so use
git rev-parse --show-toplevel
helper command instead. Just in case.Relevant docs:
git rev-parse --show-toplevel