Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,23 @@ public function guessChromeBinaryPath(): string
case 'Windows':
return self::getFromRegistry() ?? '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe';
default:
return \rtrim(\explode("\n", (string) self::shellExec('command -v google-chrome chromium-browser chrome chromium'), 2)[0]) ?: 'chrome';
$valid_names = [
'google-chrome',
'chromium-browser',
'chrome',
'chromium',
];
foreach (\explode(\PATH_SEPARATOR, \getenv('PATH')) as $dir) {
foreach ($valid_names as $name) {
$file = $dir.\DIRECTORY_SEPARATOR.$name;
if (\is_file($file) && \is_executable($file)) {
return $file;
}
}
}

return 'chrome'; // ... very unlikely to actually work, but this retains the original behavior..
// throw new \RuntimeException('Could not find chrome binary'); // this makes more sense tbh
}
}

Expand Down