find-bin
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

find-bin

npm version npm download Node.js CI CodeQL codecov Maintainability FOSSA Status

To check if the command exists and where the executable file is, WITHOUT using child_process.

npm install find-bin
yarn add find-bin

Example usage

const { lookpath, lookpathSync } = require('find-bin');

const p = await lookpath('bash');
const pSync = lookpathSync('bash');
// "/bin/bash", otherwise "undefined"

Advanced usage

const p = await lookpath('bash', {
    include: ['/home/hiromu/.bin'],
    exclude: ['/mnt'],
});
// include: Do scan also under `~/.bin`
// exclude: Do NOT scan under `/mnt`
const p = await lookpath('bash', {
    includeCommonPaths: true,
});
// includeCommonPaths: Will scan for bash in many common binary directories, not just those specified in PATH
const p = await lookpath('bash', {
    findAll: true,
});
// ["/bin/bash"], an array containing all the bash binaries found in any path
// includeCommonPaths: Will scan for bash in many common binary directories, not just those specified in PATH

Motivation

Package Sidebar

Install

npm i find-bin

Weekly Downloads

568

Version

1.1.0

License

MIT

Unpacked Size

26.9 kB

Total Files

11

Last publish

Collaborators

  • jonluca