From 41ef47bd40c14ce5528494027d80cdfce2b25928 Mon Sep 17 00:00:00 2001 From: Vishal Khode Date: Fri, 29 Nov 2024 00:37:46 +0530 Subject: [PATCH] ISSUE-75: Added example on skipping settings.php generation. --- .../src/Drush/Commands/ExampleDrushCommands.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php b/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php index 3e72bf9..875198d 100644 --- a/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php +++ b/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php @@ -3,10 +3,12 @@ namespace Example\Drush\Commands; use Acquia\Drupal\RecommendedSettings\Drush\Commands\MultisiteDrushCommands; +use Acquia\Drupal\RecommendedSettings\Drush\Commands\SettingsDrushCommands; use Consolidation\AnnotatedCommand\CommandData; use Consolidation\AnnotatedCommand\Hooks\HookManager; use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; +use Robo\ResultData; /** * An example drush command file. @@ -34,4 +36,17 @@ public function showSuccessMessage(CommandData $commandData): void { $this->io()->info("The settings.php generated successfully for site `" . $uri . "`."); } + /** + * Skip settings.php generation if current environment is CI environment. + */ + #[CLI\Hook(type: HookManager::PRE_COMMAND_HOOK, target: SettingsDrushCommands::SETTINGS_COMMAND)] + public function validate(): ?ResultData { + $isCI = getenv('CI'); + if (!$isCI) { + return NULL; + } + $this->io()->info("Skip settings.php generation for CI environment."); + return new ResultData(ResultData::EXITCODE_OK); + } + }