package
The minimum and most straightforward way to check if command exists and where the executable is.
npm install lookpathGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
16.4 kB
Includes dependencies.
To check if the command exists and where the executable file is, WITHOUT using child_process.
npm install lookpathconst { lookpath } = require('lookpath');
const p = await lookpath('bash');
// "/bin/bash", otherwise "undefined"const p = await lookpath('bash', {
include: ['/home/hiromu/.bin'],
exclude: ['/mnt']
});
// include: Do scan also under `~/.bin`
// exclude: Do NOT scan under `/mnt`child_process in order to kick which, where, whereis, or command -v.
exec.LookPath.
Any feedback would be appreciated ;)
$PATH or $Path is the best straightforward way to check if the command exists.