Skip to content

Commit

Permalink
ISSUE-75: Added example on skipping settings.php generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkhode1 committed Dec 6, 2024
1 parent 52acbb4 commit 625c311
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 625c311

Please sign in to comment.