Skip to content

Commit 41ef47b

Browse files
committed
ISSUE-75: Added example on skipping settings.php generation.
1 parent 691c63f commit 41ef47b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php

+15
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace Example\Drush\Commands;
44

55
use Acquia\Drupal\RecommendedSettings\Drush\Commands\MultisiteDrushCommands;
6+
use Acquia\Drupal\RecommendedSettings\Drush\Commands\SettingsDrushCommands;
67
use Consolidation\AnnotatedCommand\CommandData;
78
use Consolidation\AnnotatedCommand\Hooks\HookManager;
89
use Drush\Attributes as CLI;
910
use Drush\Commands\DrushCommands;
11+
use Robo\ResultData;
1012

1113
/**
1214
* An example drush command file.
@@ -34,4 +36,17 @@ public function showSuccessMessage(CommandData $commandData): void {
3436
$this->io()->info("The settings.php generated successfully for site `" . $uri . "`.");
3537
}
3638

39+
/**
40+
* Skip settings.php generation if current environment is CI environment.
41+
*/
42+
#[CLI\Hook(type: HookManager::PRE_COMMAND_HOOK, target: SettingsDrushCommands::SETTINGS_COMMAND)]
43+
public function validate(): ?ResultData {
44+
$isCI = getenv('CI');
45+
if (!$isCI) {
46+
return NULL;
47+
}
48+
$this->io()->info("Skip settings.php generation for CI environment.");
49+
return new ResultData(ResultData::EXITCODE_OK);
50+
}
51+
3752
}

0 commit comments

Comments
 (0)