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 eb854df commit 468fcb9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
"autoload": {
"psr-4": {
"Orchestra\\DuskUpdater\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Orchestra\\DuskUpdater\\Tests\\": "tests/"
}
},
"require": {
Expand Down
2 changes: 1 addition & 1 deletion src/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function rename(string $binary, string $os): void
throw new RuntimeException("Unable to rename {$binary} without --install-dir");
}

$newName = array_reverse(explode(DIRECTORY_SEPARATOR, str_replace('chromedriver', 'chromedriver-'.$os, $binary), 2))[0];
$newName = chromedriver_binary_filename($binary, $os);

rename($this->directory.$binary, $this->directory.$newName);

Expand Down
10 changes: 10 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Orchestra\DuskUpdater;

function chromedriver_binary_filename(string $binary, string $os): string
{
return strpos($binary, DIRECTORY_SEPARATOR) > 0
? array_reverse(explode(DIRECTORY_SEPARATOR, str_replace('chromedriver', 'chromedriver-'.$os, $binary), 2))[0]
: str_replace('chromedriver', 'chromedriver-'.$os, $binary);
}

0 comments on commit 468fcb9

Please sign in to comment.