From c692470eb6a1941cbf9b2b4525bae34a7b6a5697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 22 Apr 2024 14:57:26 +0200 Subject: [PATCH] qa: add a warning when the tool is not installed --- .castor/qa.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.castor/qa.php b/.castor/qa.php index b068c4d..84e5cf6 100644 --- a/.castor/qa.php +++ b/.castor/qa.php @@ -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; @@ -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'); }