You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

bin2npm

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bin2npm

A cli tool by @bjesuiter which takes one or more binaries for different platforms and wraps them into an npm package for distribution. Can also be used via bin2npm package on npmjs.org

0.0.7
latest
npmnpm
Version published
Maintainers
1
Created
Source

bin2npm

JSR NPM Version

A helper cli which takes one or more binaries for different platforms and wraps them into an npm package for distribution.

Run/Install via deno (from jsr.io)

Opt1: Run directly from JSR

deno run --allow-read='.' --allow-write='.' jsr:@bjesuiter/bin2npm --config ./bin2npm.toml

Opt2: Install globally on your host machine from JSR

deno install --global --allow-read='.' --allow-write='.' -n bin2npm jsr:@bjesuiter/bin2npm

Run/Install via npm

Package URL: https://www.npmjs.com/package/bin2npm

Opt1: Run directly from npm

# with config file search
npx bin2npm

# with explicit config file
npx bin2npm --config ./bin2npm.toml

Opt2: Install on your host machine from npm

# global install
npm i -g bin2npm

# local install
npm i -D bin2npm

Run/Install via bun

Package URL: https://www.npmjs.com/package/bin2npm

Opt1: Run directly from bun

bunx bin2npm --config ./bin2npm.toml

Opt2: Install globally on your host machine from bun

# global install
bun i -g bin2npm

# local install
bun i -D bin2npm

Usage (for all: deno, npm & bun)

  • Write a config file (see: example config file)
  • Run bin2npm (only works when installed globally, alternatively use npx, bunx, or direct running via jsr) => It will search for all bin2npm.toml files inside your CWD
  • Alternatively, run bin2npm --config ./bin2npm.toml to specify a config file directly
  • Finished! If your config was correct, then your output npm package should be in your configured output dir!

If you have any issues, please open an Issue at: https://github.com/bjesuiter/bin2npm/issues

Example Config

# File: bin2npm.toml
bin2NpmVersion = "0"
outDir         = "npm"

[targetPackageJson]
    name        = "bin2npm"
    version     = "0.0.6"
    description = "A cli tool by @bjesuiter which takes one or more binaries for different platforms and wraps them into an npm package for distribution. Can also be used via bin2npm package on npmjs.org"

[[binaries]]
    # path to the binary you want to wrap, based on the cwd where you run bin2npm
    path = "compiled/bin2npm_linux_x64"
    # platform should be one of nodejs's os.platform() values:
    # for Node 16 LTS: 'aix', 'darwin', 'freebsd','linux', 'openbsd', 'sunos', and 'win32'
    # see https://nodejs.org/docs/latest-v16.x/api/os.html#osplatform
    # These are only the allowed values. You have to provide the correct binary for this to work.
    platform = "linux"
    # arch should be one of nodejs's os.arch() values:
    # for Node 16 LTS: 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64'
    # see https://nodejs.org/docs/latest-v16.x/api/os.html#osarch
    # These are only the allowed values. You have to provide the correct binary for this to work.
    arch = "x64"

[[binaries]]
    path     = "compiled/bin2npm_macos_x64"
    platform = "darwin"
    arch     = "x64"

[[binaries]]
    path     = "compiled/bin2npm_macos_arm"
    platform = "darwin"
    arch     = "arm64"

[[binaries]]
    path     = "compiled/bin2npm_windows_x64.exe"
    platform = "win32"
    arch     = "x64"

# copy extra files from the current directory into the npm package
[[extraAssets]]
    from = "Readme.md"
    to   = "Readme.md"

Dev Docs

Asset building for compilation

Use asset-builder from (https://jsr.io/@codemonument/asset-builder) to have the template folder available to the deno cli. Run deno task pack-assets to pack the files in /template into src/gen/assets.ts Must be used in the npm AND the deno variant of this package, otherwise this cli will not work when installed from jsr.io!

Releasing a new version (for JSR and npm)

  • Increase versions:
    • In cli.ts for the bin2npm cli --version command
    • In deno.jsonc for the JSR deployment of this package
    • Of target npm package by updating the version in ./bin2npm.toml
    • In Changelog here at the bottom of the readme
  • Run deno task pack-assets
  • Commit all changes
  • Add a new git tag for your new version and push it => will trigger the deploy-npm.yml github workflow and the publish-jsr workflow

For deploying manually, run

  • deno task compile to compile the deno scripts with the deno executable into self-contained executables
  • deno task assemble-npm => This runs bin2npm on the compiled output of itself! (Great, isn't it?!?)
  • deno task publish-npm to publish on npm

Changelog

0.0.7 - 2025-04-04

  • add config example to readme

0.0.6 - 2025-04-03

  • fix bin field formatting in package.json generated by bin2npm => this might fix the build error of the publish-npm workflow on Github Actions

0.0.5 - 2025-04-03

  • Update dependencies and add jsr deployment

0.0.4 - 2023-06-10

  • First Version built by Github Actions

0.0.3 - 2023-06-10

  • Fix missing assets for both deno.land/x and npm, by inlining the assets as base64

0.0.2 - 2023-06-10

  • Fixing stdin of wrapped child processes, was not attached to process.stdin before, so selecting the config to use was not possible!

0.0.1 - 2023-06-10

  • initial release

FAQs

Package last updated on 04 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts