-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yarn
conditional may be unreachable in hook template.
#241
Comments
Also, I'm happy to open a PR that implements this change if the maintainers would like to swap the two conditionals. |
dannobytes
added a commit
to dannobytes/lefthook
that referenced
this issue
Oct 11, 2021
Resolves evilmartians#241 For devs who are using yarn as their package manager, the git hook templates are conditioned so that it will never attempt to run `yarn lefthook` from the local package it is installed in. Instead, the conditional will always end with `npx @arkweid/lefthook` which ends up fetching the package via network. In the worst case, the dev will fetch this package twice, once in the `elif` conditional and again within the `then` block, causing a significiant delay before the lefthook binary is executed. This degrades performance to an almost unusable state. To fix, give `yarn` a chance to find the lefthook binary within its local cache before moving on to `npx`.
Got a PR up with the suggested change, hopefully this helps. |
mrexox
pushed a commit
that referenced
this issue
Mar 31, 2022
Resolves #241 For devs who are using yarn as their package manager, the git hook templates are conditioned so that it will never attempt to run `yarn lefthook` from the local package it is installed in. Instead, the conditional will always end with `npx @arkweid/lefthook` which ends up fetching the package via network. In the worst case, the dev will fetch this package twice, once in the `elif` conditional and again within the `then` block, causing a significiant delay before the lefthook binary is executed. This degrades performance to an almost unusable state. To fix, give `yarn` a chance to find the lefthook binary within its local cache before moving on to `npx`.
Now in master, going to release it in v0.8.0 |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The hook template currently contains this logic:
However, I'm not sure it's possible for the yarn branch to ever execute. I think, if yarn is installed, npx will almost certainly be installed. If
npx
is available on the machine, it will automatically download and run@arkweid/lefthook
.I think these branches should be swapped. The yarn branch should only work if lefthook is already installed locally. If it's not already available locally, falling back to npx seems like a good option.
Alternatively, npx has a
--no-install
flag that will prevent it from automatically installing lefthook.The text was updated successfully, but these errors were encountered: