Reputation: 1161
Is there a function in node.js to find an executable file which is located somewhere in the $PATH
, similar to which
builtin of Bash?
If not, I could always try to parse process.env.PATH
and manually search in each directory, but I would rather avoid that if possible.
Upvotes: 3
Views: 4433
Reputation: 5074
You might want to check out which module
var which = require('which');
which('ls', function(err, result) {
console.log(result); // prints '/bin/ls' on mac
});
Upvotes: 13