Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jul 21, 2023
1 parent 573898f commit c6036cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 3 additions & 10 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ protected function fetchUrl(string $url): string
/**
* Resolve the download url.
*
* @return array{0: string, 1: string}
*
* @throws \Exception
*/
protected function resolveDownloadUrl(string $version, string $slug): array
protected function resolveDownloadUrl(string $version, string $slug): string
{
if (version_compare($version, '113.0', '<')) {
if ($slug == 'mac_arm64' && version_compare($version, '106.0.5249', '<')) {
Expand All @@ -106,10 +104,7 @@ protected function resolveDownloadUrl(string $version, string $slug): array
$slug = 'win';
}

return [
sprintf('https://chromedriver.storage.googleapis.com/%s/chromedriver_%s.zip', $version, $slug),
$slug,
];
return sprintf('https://chromedriver.storage.googleapis.com/%s/chromedriver_%s.zip', $version, $slug);
}

$milestone = (int) $version;
Expand All @@ -127,9 +122,7 @@ protected function resolveDownloadUrl(string $version, string $slug): array
$chromedrivers = $versions['milestones'][$milestone]['downloads']['chromedriver']
?? throw new Exception('Could not get the ChromeDriver version.');

$url = collect($chromedrivers)->firstWhere('platform', $slug)['url']
return collect($chromedrivers)->firstWhere('platform', $slug)['url']
?? throw new Exception('Could not get the ChromeDriver version.');

return [$url, $slug];
}
}
4 changes: 1 addition & 3 deletions src/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function version(InputInterface $input): string
*/
protected function download(string $version, string $slug): string
{
[$url, $slug] = $this->resolveDownloadUrl($version, $slug);
$url = $this->resolveDownloadUrl($version, $slug);

file_put_contents(
$archive = $this->directory.'chromedriver.zip',
Expand Down Expand Up @@ -120,8 +120,6 @@ protected function extract(string $version, string $archive): string

$binary = $zip->getNameIndex(version_compare($version, '113.0', '<') ? 0 : 1);

var_dump($binary);

$zip->close();

unlink($archive);
Expand Down

0 comments on commit c6036cb

Please sign in to comment.