Skip to content

The minimum and most straightforward way to check if command exists and where the executable is, without spawning child_process.

License

Notifications You must be signed in to change notification settings

otiai10/lookpath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6ae8db · Jan 7, 2025
Jan 7, 2025
May 27, 2019
Jul 29, 2021
Jul 29, 2021
Dec 23, 2019
May 7, 2019
Feb 27, 2021
May 27, 2019
Jan 10, 2022
Jan 7, 2025
Aug 1, 2024
May 27, 2019

Repository files navigation

lookpath

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 lookpath

Example usage

const { lookpath } = require('lookpath');

const p = await lookpath('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`

Motivation

Issues

Any feedback would be appreciated ;)

License

FOSSA Status