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 Aug 13, 2024
1 parent 567db38 commit 53ec6e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- '8.0'
- 8.1
- 8.2
- 8.3
dependencies:
- "highest"
- "lowest"
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@
"composer-runtime-api": "^2.2",
"composer/semver": "^1.5 || ^3.0",
"guzzlehttp/guzzle": "^7.2",
"illuminate/support": ">=5.7.0",
"symfony/console": "^4.3.4 || ^5.0 || ^6.0",
"symfony/polyfill-ctype": "^1.9",
"symfony/process": "^4.3.4 || ^5.0 || ^6.0"
},
"require-dev": {
"laravel/dusk": "^6.0 || ^7.0",
"laravel/dusk": "^6.0 || ^7.0 || ^8.0",
"phpstan/phpstan": "^1.10.7",
"phpunit/phpunit": "^9.6"
},
"conflict": {
"laravel/dusk": ">=9.0.0"
},
"config": {
"sort-packages": true
},
Expand Down
22 changes: 12 additions & 10 deletions src/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Orchestra\DuskUpdater;

use Exception;
use Illuminate\Support\Str;
use RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -91,25 +92,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);

switch (true) {
case version_compare($version, '115.0', '<'):
$index = 0;
break;
case version_compare($version, '127.0', '<'):
$index = 1;
for ($fileIndex = 0; $fileIndex < $zip->numFiles; $fileIndex++) {
$filename = $zip->getNameIndex($fileIndex);

if (Str::startsWith(basename($filename), 'chromedriver')) {

Check failure on line 106 in src/UpdateCommand.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (locked)

Parameter #1 $path of function basename expects string, string|false given.
$binary = $filename;

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

Check failure on line 109 in src/UpdateCommand.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest (locked)

Parameter #2 $files of method ZipArchive::extractTo() expects array<string>|string|null, string|false given.

break;
default:
$index = 2;
}
}

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

$zip->close();

unlink($archive);
Expand Down

0 comments on commit 53ec6e1

Please sign in to comment.