Skip to content

Commit

Permalink
qa: add a warning when the tool is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Apr 22, 2024
1 parent 0313f26 commit c692470
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .castor/qa.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Castor\Attribute\AsTask;

use function Castor\io;
use function Castor\variable;
use function docker\docker_compose_run;
use function docker\docker_exit_code;

Expand Down Expand Up @@ -37,12 +38,24 @@ function install(): void
#[AsTask(description: 'Runs PHPStan', aliases: ['phpstan'])]
function phpstan(): int
{
if (!is_dir(variable('root_dir') . '/tools/phpstan/vendor')) {
io()->error('PHPStan is not installed. Run `castor qa:install` first.');

return 1;
}

return docker_exit_code('phpstan', workDir: '/var/www');
}

#[AsTask(description: 'Fixes Coding Style', aliases: ['cs'])]
function cs(bool $dryRun = false): int
{
if (!is_dir(variable('root_dir') . '/tools/php-cs-fixer/vendor')) {
io()->error('PHPStan is not installed. Run `castor qa:install` first.');

return 1;
}

if ($dryRun) {
return docker_exit_code('php-cs-fixer fix --dry-run --diff', workDir: '/var/www');
}
Expand Down

0 comments on commit c692470

Please sign in to comment.