index.js
function exists(cmd) {
  return run(`which ${cmd}`).then(stdout => {
    if (stdout.trim().length === 0) {
      // maybe an empty command was supplied?
      // are we running on Windows??
      return Promise.reject(new Error("No output"));
    }

    const rNotFound = /^[\w\-]+ not found/g;

    if (rNotFound.test(cmd)) {
      return Promise.resolve(false);
    }

    return Promise.resolve(true);
  });
}
function exists(cmd) {
  return run(`which ${cmd}`).then(stdout => {
    if (stdout.trim().length === 0) {
      // maybe an empty command was supplied?
      // are we running on Windows??
      return Promise.reject(new Error("No output"));
    }

    const rNotFound = /^[\w\-]+ not found/g;

    if (rNotFound.test(cmd)) {
      return Promise.resolve(false);
    }

    return Promise.resolve(true);
  });
}
function exists ( cmd ) { return run ( ` ${ cmd } ` ) . then ( stdout => { if ( stdout . trim ( ) . length === 0 ) { // maybe an empty command was supplied? // are we running on Windows?? return Promise . reject ( new Error ( "No output" ) ) ; } const rNotFound = / ^[\w\-]+ not found / g ; if ( rNotFound . test ( cmd ) ) { return Promise . resolve ( false ) ; } return Promise . resolve ( true ) ; } ) ; }
returns Promise which fulfills with true if command exists
returns Promise which fulfills with true if command exists