lib/find_chrome.js
function linux(canary) {
  let installations = [];

  // Look into the directories where .desktop are saved on gnome based distro's
  const desktopInstallationFolders = [
    path.join(require('os').homedir(), '.local/share/applications/'),
    '/usr/share/applications/',
  ];
  desktopInstallationFolders.forEach(folder => {
    installations = installations.concat(findChromeExecutables(folder));
  });

  // Look for google-chrome(-stable) & chromium(-browser) executables by using the which command
  const executables = [
    'google-chrome-stable',
    'google-chrome',
    'chromium-browser',
    'chromium',
  ];
  executables.forEach(executable => {
    try {
      const chromePath =
          execFileSync('which', [executable], {stdio: 'pipe'}).toString().split(newLineRegex)[0];
      if (canAccess(chromePath))
        installations.push(chromePath);
    } catch (e) {
      // Not installed.
    }
  });

  if (!installations.length)
    throw new Error('The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.');

  const priorities = [
    {regex: /chrome-wrapper$/, weight: 51},
    {regex: /google-chrome-stable$/, weight: 50},
    {regex: /google-chrome$/, weight: 49},
    {regex: /chromium-browser$/, weight: 48},
    {regex: /chromium$/, weight: 47},
  ];

  if (process.env.CHROME_PATH)
    priorities.unshift({regex: new RegExp(`${process.env.CHROME_PATH}`), weight: 101});

  return sort(uniq(installations.filter(Boolean)), priorities)[0];
}
function linux(canary) {
  let installations = [];

  // Look into the directories where .desktop are saved on gnome based distro's
  const desktopInstallationFolders = [
    path.join(require('os').homedir(), '.local/share/applications/'),
    '/usr/share/applications/',
  ];
  desktopInstallationFolders.forEach(folder => {
    installations = installations.concat(findChromeExecutables(folder));
  });

  // Look for google-chrome(-stable) & chromium(-browser) executables by using the which command
  const executables = [
    'google-chrome-stable',
    'google-chrome',
    'chromium-browser',
    'chromium',
  ];
  executables.forEach(executable => {
    try {
      const chromePath =
          execFileSync('which', [executable], {stdio: 'pipe'}).toString().split(newLineRegex)[0];
      if (canAccess(chromePath))
        installations.push(chromePath);
    } catch (e) {
      // Not installed.
    }
  });

  if (!installations.length)
    throw new Error('The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.');

  const priorities = [
    {regex: /chrome-wrapper$/, weight: 51},
    {regex: /google-chrome-stable$/, weight: 50},
    {regex: /google-chrome$/, weight: 49},
    {regex: /chromium-browser$/, weight: 48},
    {regex: /chromium$/, weight: 47},
  ];

  if (process.env.CHROME_PATH)
    priorities.unshift({regex: new RegExp(`${process.env.CHROME_PATH}`), weight: 101});

  return sort(uniq(installations.filter(Boolean)), priorities)[0];
}
function linux ( canary ) { let installations = [ ] ; // Look into the directories where .desktop are saved on gnome based distro's const desktopInstallationFolders = [ path . join ( require ( 'os' ) . homedir ( ) , '.local/share/applications/' ) , '/usr/share/applications/' , ] ; desktopInstallationFolders . forEach ( folder => { installations = installations . concat ( findChromeExecutables ( folder ) ) ; } ) ; // Look for google-chrome(-stable) & chromium(-browser) executables by using the which command const executables = [ 'google-chrome-stable' , 'google-chrome' , 'chromium-browser' , 'chromium' , ] ; executables . forEach ( executable => { try { const chromePath = execFileSync ( 'which' , [ executable ] , { stdio : 'pipe' } ) . toString ( ) . split ( newLineRegex ) [ 0 ] ; if ( canAccess ( chromePath ) ) installations . push ( chromePath ) ; } catch ( e ) { // Not installed. } } ) ; if ( ! installations . length ) throw new Error ( 'The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later.' ) ; const priorities = [ { regex : / chrome-wrapper$ / , weight : 51 } , { regex : / google-chrome-stable$ / , weight : 50 } , { regex : / google-chrome$ / , weight : 49 } , { regex : / chromium-browser$ / , weight : 48 } , { regex : / chromium$ / , weight : 47 } , ] ; if ( process . env . CHROME_PATH ) priorities . unshift ( { regex : new RegExp ( ` ${ process . env . CHROME_PATH } ` ) , weight : 101 } ) ; return sort ( uniq ( installations . filter ( Boolean ) ) , priorities ) [ 0 ] ; }
Look for linux executables in 3 ways
1. Look into CHROME_PATH env variable
2. Look into the directories where .desktop are saved on gnome based distro's
3. Look for google-chrome-stable & google-chrome executables by using the which command
Look for linux executables in 3 ways 1 . Look into CHROME_PATH env variable 2 . Look into the directories where . desktop are saved on gnome based distro s 3 . Look for google - chrome - stable & google - chrome executables by using the which command