Skip to content

Commit

Permalink
StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
divinity76 authored Mar 19, 2024
1 parent 9ef7a46 commit 4014c1b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ public function guessChromeBinaryPath(): string
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
case 'Windows':
return self::getFromRegistry() ?? '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe';
default: {
$valid_names = array(
'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;
}
default:
$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
}

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

0 comments on commit 4014c1b

Please sign in to comment.