Skip to content

Commit

Permalink
[MERGE]: develop to main
Browse files Browse the repository at this point in the history
  • Loading branch information
asciito authored Dec 6, 2023
2 parents fab05c7 + 597b120 commit 9d5157f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ This will spin-up two servers, one in port `9515`, and the second one in port `9
be used with the other three other actions: `stop`, `restart`, and `status`.

> **Note**:
> This comand can only be use with the first four actions: `start`, `stop`, `restart`, and `status`.
> This option only can be used with the first four actions: `start`, `stop`, `restart`, and `status`.
The second one is just to specify where to search for the Chrome Driver binary, you just need to specify the option
`--path`.
Expand Down
17 changes: 9 additions & 8 deletions app/Commands/DriverManagerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Commands;

use App\Commands\Exceptions\DoesNotSupportWindowsException;
use App\Commands\Exceptions\FailCommandException;
use App\OperatingSystem;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -100,7 +101,7 @@ protected function start(string $port): int

return self::FAILURE;
}
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot start the server');

return self::FAILURE;
Expand All @@ -124,7 +125,7 @@ public function stop(string $port): int

try {
$pid = $this->getProcessID($port);
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot stop the server');

return self::FAILURE;
Expand All @@ -149,7 +150,7 @@ protected function restart(string $port): int

try {
$pid = $this->getProcessID($port);
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot restart the server');

return self::FAILURE;
Expand All @@ -176,7 +177,7 @@ protected function status(string $port): int

try {
$pid = $this->getProcessID($port);
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot be sure if the server is running, but we will try to check');
}

Expand Down Expand Up @@ -210,7 +211,7 @@ protected function list(): int

try {
$result = $this->getProcessIDs();
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot list the servers');

return self::FAILURE;
Expand All @@ -234,7 +235,7 @@ protected function kill(): int
{
try {
$pids = $this->getProcessIDs();
} catch (\Exception) {
} catch (DoesNotSupportWindowsException) {
warning('We are running on windows and we cannot stop the servers');

return self::FAILURE;
Expand Down Expand Up @@ -294,7 +295,7 @@ protected function command(string $cmd, array $with): ProcessResult
protected function getProcessID(string $port): ?int
{
if ($this->onWindows()) {
throw new \Exception('We cannot get a server PID on Windows');
throw new DoesNotSupportWindowsException;
}

$process = $this->command('pid', ['{options}' => '--port='.$port]);
Expand All @@ -307,7 +308,7 @@ protected function getProcessID(string $port): ?int
protected function getProcessIDs(): ?Collection
{
if ($this->onWindows()) {
throw new \Exception('We cannot get the servers PID on Windows');
throw new DoesNotSupportWindowsException;
}

$process = $this->command('pid', ['{options}' => '']);
Expand Down
11 changes: 11 additions & 0 deletions app/Commands/Exceptions/DoesNotSupportWindowsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Commands\Exceptions;

class DoesNotSupportWindowsException extends \Exception
{
public function __construct()
{
parent::__construct('This command is not supported on Windows.');
}
}
2 changes: 1 addition & 1 deletion app/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function version(): ?GoogleDownloadable
return GoogleForTesting::getVersion($version);
}

protected function getBasePath(string $path = null): string
protected function getBasePath(?string $path = null): string
{
$folder = join_paths(getenv('HOME'), '.google-for-testing');

Expand Down
2 changes: 1 addition & 1 deletion app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function download(string $url, string $file, bool $force = false): void
* @param string $filename The file name of the ZIP file
* @param ?string $to The location where to extract the content
*/
function unzip(string $filename, string $to = null): void
function unzip(string $filename, ?string $to = null): void
{
if (! extension_loaded('zip')) {
throw new \RuntimeException('Extension [ext-zip] not found');
Expand Down
Binary file modified builds/google-for-testing
Binary file not shown.

0 comments on commit 9d5157f

Please sign in to comment.