lib/common.js
function lookForBinary(binary, pathList) {
  let envPath = _.toArrayIfNeeded(pathList);
  if (_.isEmpty(envPath)) {
    envPath = (process.env.PATH || '').split(path.delimiter);
  }
  const foundPath = _.first(_.filter(envPath, (dir) => {
    return fileExists(path.join(dir, binary));
  }));
  return foundPath ? path.join(foundPath, binary) : null;
}
function lookForBinary(binary, pathList) {
  let envPath = _.toArrayIfNeeded(pathList);
  if (_.isEmpty(envPath)) {
    envPath = (process.env.PATH || '').split(path.delimiter);
  }
  const foundPath = _.first(_.filter(envPath, (dir) => {
    return fileExists(path.join(dir, binary));
  }));
  return foundPath ? path.join(foundPath, binary) : null;
}
function lookForBinary ( binary , pathList ) { let envPath = _ . toArrayIfNeeded ( pathList ) ; if ( _ . isEmpty ( envPath ) ) { envPath = ( process . env . PATH || '' ) . split ( path . delimiter ) ; } const foundPath = _ . first ( _ . filter ( envPath , ( dir ) => { return fileExists ( path . join ( dir , binary ) ) ; } ) ) ; return foundPath ? path . join ( foundPath , binary ) : null ; }
Get full path to a binary in the provided list of directories
@function lookForBinary
@private
@param {string} binary - Binary to look for
@param {string[]} [pathList] - List of directories in which to locate the binary.
If it is not provided or is empty, the system PATH will be used
@returns {string} - The full path to the binary or null if it is not in the PATH
@example
// Get the path of the 'node' binary in the System PATH
lookForBinary('node');
=> '/usr/local/bin/node'
Get full path to a binary in the provided list of directories