Closed dalisoft closed 2 months ago
Hey! Lefthook actually implements different ways of distribution. We have lefthook
package that utilized optionalDepdencies
, we have @evilmartians/lefthook-installer
which downloads the binary in a postinstall step and we have @evilmartians/lefthook
which simply contains all the binaries.
So, what is your suggestion for improvement? And what is the problem with current npm packages you see?
I looked into other ways of distribution and it is actually 30% slower than suggested improvements.
I am suggesting using direct binary for package.json
like {"bin":"lefthook.exe"}
or {"bin":"lefthook"}
so no additional overhead when executing lefthook
from CLI
Currently no problem but only 30% performance loss and after improvement CLI speed for npm
could be improved by 30%
Oh, I see. Ok, I agree, it would be great to have this improvement.
@mrexox See #705 please
:zap: Summary
Hi @evilmartians team/contributors
Tuning
npm
package could lead into performance improvements and reducing startup execution.Opened similar PR/Issue on other projects but impossible to check locally due of hard running local or lacking of running locally easier script.
As these PR not merged into neither of them, so first decided to ask from you
Value
../lint-staged.sh
lint-staged
lefthook run pre-commit
./lefthook run pre-commit
Behavior and configuration changes
If
npx
is not important, can be tuned for usinglefthook
binary fromoptionalDependencies
or prepare script can download and change binary for mainnpm
packagebin
field.Test script locally for you
```js import { prepare, maps } from "binary2npm"; maps.os = { linux: "Linux", freebsd: "Freebsd", darwin: "MacOS", win32: "Windows", }; maps.arch = { arm64: "arm64", x64: "x86_64", x86: "x86_64", }; await prepare({ remote: "github", author: "evilmartians", repository: "lefthook", remoteToken: process.env.GITHUB_TOKEN, binary: "lefthook", orders: ["binary", "version", "os", "arch"], }); ```postinstall.js
node postinstall.js
bin.js
fromnpm
package