Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
bin-wrapper
Advanced tools
Binary wrapper that makes your programs seamlessly available as local dependencies
The bin-wrapper npm package is a utility that helps you download and manage binaries for your Node.js projects. It allows you to specify a binary, download it if necessary, and make it available for use in your project. This is particularly useful for ensuring that the correct version of a binary is used, regardless of the environment in which your code is running.
Download and manage binaries
This feature allows you to specify different sources for binaries based on the operating system and architecture. The code sample demonstrates how to set up a BinWrapper instance to download the gifsicle binary for different platforms and run it to check its version.
const BinWrapper = require('bin-wrapper');
const path = require('path');
const base = 'https://raw.githubusercontent.com/imagemin/gifsicle-bin/main/vendor';
const bin = new BinWrapper()
.src(`${base}/macos/gifsicle`, 'darwin')
.src(`${base}/linux/x64/gifsicle`, 'linux', 'x64')
.src(`${base}/win/x64/gifsicle.exe`, 'win32', 'x64')
.dest(path.join(__dirname, 'vendor'))
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle');
bin.run(['--version']).then(() => {
console.log('Binary is working');
}).catch(err => {
console.error('Binary failed to run', err);
});
node-pre-gyp is a tool that makes it easy to publish and install Node.js C++ addons from binaries. It provides a way to package and distribute precompiled binaries, which can be downloaded and used without requiring users to compile the code themselves. Compared to bin-wrapper, node-pre-gyp is more focused on C++ addons and their distribution, whereas bin-wrapper is more general-purpose for managing any kind of binary.
nexe is a command-line utility that compiles your Node.js application into a single executable file. It includes the Node.js runtime and your application code, making it easy to distribute and run your application on different systems. While bin-wrapper focuses on downloading and managing external binaries, nexe is about packaging your Node.js application into a standalone binary.
pkg is a tool that packages Node.js projects into executable files for different platforms. It allows you to create a single executable that includes your application code and the Node.js runtime. Similar to nexe, pkg is focused on creating standalone executables, whereas bin-wrapper is about managing external binaries that your project depends on.
Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies
$ npm install --save bin-wrapper
var BinWrapper = require('bin-wrapper');
var bin = new BinWrapper({ bin: 'gifsicle', version: '1.71', dest: 'vendor' });
bin
.addUrl('https://raw.github.com/yeoman/node-gifsicle/0.1.4/vendor/osx/gifsicle', 'darwin')
.addUrl('https://raw.github.com/yeoman/node-gifsicle/0.1.4/vendor/linux/x64/gifsicle', 'linux', 'x64')
.addSource('http://www.lcdf.org/gifsicle/gifsicle-1.71.tar.gz')
.check()
.on('error', function (err) {
console.log(err);
});
.on('fail', function () {
this.build('./configure && make && make install')
})
.on('success', function () {
console.log('gifsicle is working');
})
.on('finish', function () {
console.log('gifsicle rebuilt successfully!')
})
Get the path to your binary with bin.path
:
console.log(bin.path); // => path/to/vendor/gifsicle
Creates a new BinWrapper
. Available options are bin
which is the name of the
binary and dest
which is where to download/build the binary to.
Check if a binary is present and working. If it isn't, download and test it by
running the binary with cmd
and see if it exits correctly.
Emits success
if the binary is working and fail
if the binary failed to exit with
status code 0
.
Download the source archive defined in the src
property and build it using the
build script defined in the cmd
argument.
Emits finish
when build is finished successfully.
Add a path where to check for the binary. By default dest
is added to paths.
Add a URL to download the binary from. Use platform
and arch
to target a
specific system.
Add a file to download alongside with the binary. Use platform
and arch
to
target a specific system.
Add a URL where to download the source code from.
Type: String
Default: undefined
Set the name of the binary.
Type: String
Default: undefined
Define a specific version.
Type: Boolean
Default: true
Whether to check for a binary globally or not.
Type: String
Default: process.cwd()
Destination to download/build binary.
FAQs
Binary wrapper that makes your programs seamlessly available as local dependencies
The npm package bin-wrapper receives a total of 636,389 weekly downloads. As such, bin-wrapper popularity was classified as popular.
We found that bin-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.