Skip to content

Commit d3bcfcb

Browse files
Merge pull request #24 from drupal-composer/post-scaffold
Introduce a pre-scaffold event and a post-scaffold event.
2 parents 9c014ef + 46a90d3 commit d3bcfcb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Handler.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
use Composer\DependencyResolver\Operation\UpdateOperation;
1313
use Composer\IO\IOInterface;
1414
use Composer\Package\PackageInterface;
15+
use Composer\EventDispatcher\EventDispatcher;
1516

1617
use Composer\Util\Filesystem;
1718
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
1819

1920
class Handler {
2021

22+
const PRE_DRUPAL_SCAFFOLD_CMD = 'pre-drupal-scaffold-cmd';
23+
const POST_DRUPAL_SCAFFOLD_CMD = 'post-drupal-scaffold-cmd';
24+
2125
/**
2226
* @var \Composer\Composer
2327
*/
@@ -102,6 +106,10 @@ public function downloadScaffold() {
102106
$excludes = $this->getExcludes();
103107
$includes = $this->getIncludes();
104108

109+
// Call any pre-scaffold scripts that may be defined.
110+
$dispatcher = new EventDispatcher($this->composer, $this->io);
111+
$dispatcher->dispatch(self::PRE_DRUPAL_SCAFFOLD_CMD);
112+
105113
// Run Robo
106114
static::execute(
107115
[
@@ -120,6 +128,9 @@ public function downloadScaffold() {
120128
static::array_to_csv($includes),
121129
]
122130
);
131+
132+
// Call post-scaffold scripts.
133+
$dispatcher->dispatch(self::POST_DRUPAL_SCAFFOLD_CMD);
123134
}
124135

125136
/**

0 commit comments

Comments
 (0)