Skip to content

Commit

Permalink
Merge branch '1.x' into 2.x
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Aug 13, 2024
2 parents 646e77b + 5530455 commit 320fce4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@
"symfony/process": "^6.0 || ^7.0"
},
"require-dev": {
"laravel/dusk": "^6.0 || ^7.0 || ^8.0",
"laravel/pint": "^1.4",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^9.6"
},
"conflict": {
"laravel/dusk": "<6.0.0 >=9.0.0"
},
"config": {
"sort-packages": true
},
Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function resolveChromeDriverDownloadUrl(string $version, string $opera
$slug = OperatingSystem::chromeDriverSlug($operatingSystem, $version);

if (version_compare($version, '115.0', '<')) {
return sprintf('https://chromedriver.storage.googleapis.com/%s/chromedriver_%s.zip', $version, $slug);
return \sprintf('https://chromedriver.storage.googleapis.com/%s/chromedriver_%s.zip', $version, $slug);
}

$milestone = (int) $version;
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/DetectsChromeVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function installedChromeDriverVersion(string $operatingSystem, string
protected function fetchChromeVersionFromUrl(int $version): string
{
return trim((string) $this->fetchUrl(
sprintf('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_%d', $version)
\sprintf('https://chromedriver.storage.googleapis.com/LATEST_RELEASE_%d', $version)
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/DetectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
isset($chromeVersions['semver']) ? $chromeVersions['semver'] : ''
);

$io->block(sprintf('Running PHP %s on Platform [%s]', PHP_VERSION, $currentOS));
$io->block(\sprintf('Running PHP %s on Platform [%s]', PHP_VERSION, $currentOS));

$io->table(['Tool', 'Version'], [
['Chrome/Chromium', $chromeVersions['semver'] ?? '<fg=yellow>✖ N/A</>'],
Expand Down
21 changes: 14 additions & 7 deletions src/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$output->writeln(sprintf(
$output->writeln(\sprintf(
'<info>ChromeDriver %s successfully installed for version %s.</info>', $all ? 'binaries' : 'binary', $version
));

Expand Down Expand Up @@ -95,19 +95,26 @@ protected function extract(string $version, string $archive): string
throw new RuntimeException("Unable to extract {$archive} without --install-dir");
}

$binary = null;

$zip = new ZipArchive;

$zip->open($archive);

$zip->extractTo($this->directory);

$index = match (true) {
version_compare($version, '115.0', '<') => 0,
version_compare($version, '127.0', '<') => 1,
default => 2,
};
for ($fileIndex = 0; $fileIndex < $zip->numFiles; $fileIndex++) {
/** @var string $filename */
$filename = $zip->getNameIndex($fileIndex);

if (str_starts_with(basename($filename), 'chromedriver')) {
$binary = $filename;

$zip->extractTo($this->directory, $binary);

$binary = $zip->getNameIndex($index);
break;
}
}

$zip->close();

Expand Down

0 comments on commit 320fce4

Please sign in to comment.