1.2.3 • Published 9 years ago

hasbin v1.2.3

Weekly downloads
134,786
License
MIT
Repository
github
Last release
9 years ago

HasBin

Check whether a binary exists in the PATH environment variable.

NPM version Node.js version support Build status Dependencies MIT licensed

var hasbin = require('hasbin');

// Check if a binary exists
hasbin('node', function (result) {
    // result === true
});
hasbin('wtf', function (result) {
    // result === false
});

// Check if all binaries exist
hasbin.all(['node', 'npm'], function (result) {
    // result === true
});

// Check if at least one binary exists
hasbin.some(['node', 'wtf'], function (result) {
    // result === true
});

// Find the first available binary
hasbin.first(['node', 'npm'], function (result) {
    // result === 'node'
});

Table Of Contents

Install

Install HasBin with npm:

npm install hasbin

Usage

hasbin(binaryName, callback)

Check whether a binary exists on one of the paths in process.env.PATH. Calls back with true if it does.

// Arguments
binaryName = String
callback = Function(Boolean)
// Example
hasbin('node', function (result) {
    // result === true
});

hasbin.sync(binaryName)

Synchronous hasbin.

// Arguments
binaryName = String
return Boolean
// Example
result = hasbin.sync('node');

hasbin.all(binaryNames, callback)

Check whether all of a set of binaries exist on one of the paths in process.env.PATH. Calls back with true if all of the binaries do. Aliased as hasbin.every.

// Arguments
binaryNames = Array(String)
callback = Function(Boolean)
// Example
hasbin.all(['node', 'npm'], function (result) {
    // result === true
});

hasbin.all.sync(binaryNames)

Synchronous hasbin.all. Aliased as hasbin.every.sync.

// Arguments
binaryNames = Array(String)
return Boolean
// Example
result = hasbin.all.sync(['node', 'npm']);

hasbin.some(binaryNames, callback)

Check whether at least one of a set of binaries exists on one of the paths in process.env.PATH. Calls back with true if at least one of the binaries does. Aliased as hasbin.any.

// Arguments
binaryNames = Array(String)
callback = Function(Boolean)
// Example
hasbin.some(['node', 'npm'], function (result) {
    // result === true
});

hasbin.some.sync(binaryNames)

Synchronous hasbin.some. Aliased as hasbin.any.sync.

// Arguments
binaryNames = Array(String)
return Boolean
// Example
result = hasbin.some.sync(['node', 'npm']);

hasbin.first(binaryNames, callback)

Checks the list of binaryNames to find the first binary that exists on one of the paths in process.env.PATH. Calls back with the name of the first matched binary if one exists and false otherwise.

// Arguments
binaryNames = Array(String)
callback = Function(String|false)
// Example
hasbin.first(['node', 'npm'], function (result) {
    // result === 'node'
});

hasbin.first.sync(binaryNames)

Synchronous hasbin.first.

// Arguments
binaryNames = Array(String)
return String|false
// Example
result = hasbin.first.sync(['node', 'npm']);

Contributing

To contribute to HasBin, clone this repo locally and commit your code on a separate branch.

Please write unit tests for your code, and check that everything works by running the following before opening a pull-request:

make ci

License

HasBin is licensed under the MIT license.
Copyright © 2015, Springer Nature

@pistazie/grvzvue-cli-plugin-alphasqaure-cordova-testvue-cli-plugin-alphasquare-cordova-testvue-cli-plugin-as-cordovagolem-sdkbebras-md@enigmampc/discovery-clicypress-lib@everything-registry/sub-chunk-1828vue-cli-plugin-cordova-oopwgslvue-cli-plugin-cordova-app-version-syncvue-cli-plugin-cordova-v2vue-cli-plugin-cordovawebbossxdlrunner-clisg-checkscrat-command-serverresin-wifivisorspindly-doctorposeuplibnmaplaravel-mix-jigsawlaravel-mix-statislaunch-android-emulatorgolangmacro-horizonlightning-talkmonopodkorelogichasbin-clihorizonh265izehacker-box-cligmiyazaki-nativefiermdtex-climediainfosls-disksnow-servepixelworld-nativefierplease-runnerpon-task-commandpomodoro-intrusiveojoomeggaoloprofoundjsnode-doranmmes-module-encodernode-libnmapmupjpg-gitphp-jsnativefiernativefier-bvcnativefier-cnnativefier-fork-davejnativefier-nextnativefier-willyb321netlify-lm-pluginnetlify-clinetlify-cli-forknwdcresin-cliresin-cli-mcsugos-travisrostarrun-my-fileshuntersltcthe-checkthe-bintransmutejstruffler@aschmidt8/netlify-cli@axway/axway-repository-cli@blitzjs/cli@abc-map/create-module@aarondill/create-tsyankeewatchinharrison-xdl@haiku/cli@hoal/substrate-client@elastosfoundation/trinity-cli@flyacts/backend@flyntwp/flynt-cli@infinitebrahmanuniverse/nolb-hasb@llblumire/vue-cli-plugin-cordova@linamar/create-express-api@linamar/create-logicapp@linamar/create-react-app@linamar/create-shared-lib@mrlowlevel/cdk-dia@expo/xdl@minowara/h265ize@ionapp/cli@jesses/nativefier@joshmoreno/jigsaw@prasadbobby/prasadbobby-native
1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago