Skip to content

Commit

Permalink
Merge pull request #25 from derekmd/feat/allow-skipping-chromedriver-…
Browse files Browse the repository at this point in the history
…check

[1.x] Add option `--skip-install-check` to `dusk:chrome`
  • Loading branch information
derekmd authored Feb 10, 2023
2 parents d61f467 + aff4b9d commit ae0747e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Console/ChromeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class ChromeCommand extends Command
*
* @var string
*/
protected $signature = 'dusk:chrome {--without-tty : Disable output to TTY}';
protected $signature = 'dusk:chrome
{--skip-install-check : Don\'t check DuskTestCase.php references ChromeDriver.}
{--without-tty : Disable output to TTY}';

/**
* The console command description.
Expand Down Expand Up @@ -49,13 +51,15 @@ public function __construct()
*/
public function handle()
{
if (! $this->hasChromedriverSetup()) {
if (! $this->option('skip-install-check') && ! $this->hasChromedriverSetup()) {
$this->info('It looks like you must configure your application for Chromedriver.');
$this->info('Run "php artisan dusk:install-firefox --with-chrome" to install new scaffolding.');

return 1;
}

$this->cleanArgv();

$duskFile = new DuskFile($this->laravel->environment());

if (! $duskFile->append($this->environmentVariable)) {
Expand All @@ -80,7 +84,7 @@ public function handle()
*/
protected function hasChromedriverSetup()
{
return Str::contains($this->duskTestCaseContents(), 'startChromeDriver()');
return Str::contains($this->duskTestCaseContents(), 'startChromeDriver');
}

/**
Expand All @@ -92,4 +96,16 @@ protected function duskTestCaseContents()
{
return file_get_contents(base_path('tests/DuskTestCase.php'));
}

/**
* Remove --skip-install-check to prevent Symfony method Command::run()
* applying invalid option: 'php artisan dusk --skip-install-check'.
*
* @return void
*/
protected function cleanArgv()
{
$_SERVER['argv'] = array_diff($_SERVER['argv'], ['--skip-install-check']);
$_SERVER['argc'] = count($_SERVER['argv']);
}
}

0 comments on commit ae0747e

Please sign in to comment.