code: 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);
    });
  }
docs: returns Promise which fulfills with true if command exists