$ gnpm install lookpath
To check if the command exists and where the executable file is, WITHOUT using child_process
.
npm install lookpath
const { 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
.
$PATH
or $Path
is the best straightforward way to check if the command exists.Any feedback would be appreciated ;)
Copyright 2013 - present © cnpmjs.org | Home |