What is bin-check?
The bin-check npm package is used to check if a binary is working by executing it with optional arguments and checking the exit code. It is useful for validating if a binary is correctly installed and operational in the environment where your Node.js application is running.
What are bin-check's main functionalities?
Check if a binary is working
This feature allows you to check if a binary is working by running it with the '--version' argument (or any other argument you wish to use) and returns a promise that resolves with a boolean indicating if the binary works.
const binCheck = require('bin-check');
binCheck('/path/to/binary', ['--version']).then(works => {
console.log(works ? 'Binary is working!' : 'Binary is not working.');
}).catch(error => {
console.error('An error occurred:', error);
});
Other packages similar to bin-check
execa
Execa is a process execution tool that is more general-purpose than bin-check. It can be used to execute binaries and handle their output, but it does not specifically check if a binary works. It provides more detailed control over the execution environment and the child process.
which
The 'which' package is a simple utility to find the path of a binary in the system's PATH. It is similar to the Unix 'which' command. Unlike bin-check, it does not execute the binary to check if it's working; it only locates it.
command-exists
This package is used to check if a given command is available in the system's PATH, similar to 'which'. It does not execute the binary but simply checks for its existence, making it less thorough than bin-check for verifying if a binary is operational.
bin-check
Check if a binary is working by checking its exit code
Install
$ npm install --save bin-check
Usage
var binCheck = require('bin-check');
binCheck('/bin/sh', ['--version'], function (err, works, msg) {
if (err) {
throw err;
}
console.log(msg);
console.log(works);
});
API
binCheck(name, cmd, cb)
Check if a binary is working by checking its exit code. Use cmd
to test against
custom commands. Defaults to --help
.
License
MIT © Kevin Mårtensson