Skip to content

dalisoft/binary2npm

Repository files navigation

binary2npm

Available posix shell version of this tool binary2sh

Prepare execution script for linking binaries from other tools/languages

Currently supports only GitHub API

Installation

npm install dalisoft/binary2npm
# or
yarn install dalisoft/binary2npm
# or
bun add dalisoft/binary2npm

Environment variables

Name Description Required
GITHUB_TOKEN For GitHub API Yes

Usage

See example

// postinstall.js
import { prepare } from "binary2npm";

await prepare({
  remote: "github",
  author: "MyGitHubUser",
  repository: "my-repo",
  remoteToken: process.env.GITHUB_TOKEN, // To avoid Github API limiting
  binary: "my-binary",
});

then add postinstall.js as hook into your projects scripts, see how it's implemented in Used for CLIs

Used for CLIs

This project was made for first entry but then improved and added support for other ways as well as Windows support added

Performance differences

Using direct binary for npm can boost performance up-to 8 times. These CLI apps are blazing fast but Node.js bin.js causing it to be slow.

Name Performance boost PR
commitlint-rs-npm No official npm
commitlint-go-npm No official npm
jsona-rs-npm No official npm
typos-rs-npm No official npm
dprint-rs-npm up to 5 times #839, #840
biome-rs-npm up to 8 times #2359
oxlint-rs-npm up to 8 times #2920
lefthook-go-npm up to 33% #705
ls-lint-go-npm up to 16 times

License

Apache-2.0