Skip to content

Commit

Permalink
Merge a6f7099 into 81c6ac7
Browse files Browse the repository at this point in the history
  • Loading branch information
phayes committed Jun 12, 2017
2 parents 81c6ac7 + a6f7099 commit e5f47b5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/MergePlugin.php
Expand Up @@ -92,6 +92,26 @@ class MergePlugin implements PluginInterface, EventSubscriberInterface
*/
const COMPAT_PLUGINEVENTS_INIT = 'init';

/**
* Name of the pre-merge command to be run before a required merge
*/
const PRE_MERGE_REQUIRED_CMD = 'pre-merge-require-cmd';

/**
* Name of the pre-merge command to be run before an optional merge
*/
const PRE_MERGE_OPTIONAL_CMD = 'pre-merge-optional-cmd';

/**
* Name of the post-merge command to be run after a required merge
*/
const POST_MERGE_REQUIRED_CMD = 'post-merge-require-cmd';

/**
* Name of the post-merge command to be run after an optional merge
*/
const POST_MERGE_OPTIONAL_CMD = 'post-merge-optional-cmd';

/**
* Priority that plugin uses to register callbacks.
*/
Expand Down Expand Up @@ -214,6 +234,10 @@ public function onInstallUpdateOrDump(ScriptEvent $event)
*/
protected function mergeFiles(array $patterns, $required = false)
{
// Dispatch any pre-merge commands
$pre_merge_command = $required ? self::PRE_MERGE_REQUIRED_CMD : self::PRE_MERGE_OPTIONAL_CMD;
$this->composer->getEventDispatcher()->dispatchScript($pre_merge_command, true);

$root = $this->composer->getPackage();

$files = array_map(
Expand All @@ -232,6 +256,10 @@ function ($files, $pattern) use ($required) {
foreach (array_reduce($files, 'array_merge', array()) as $path) {
$this->mergeFile($root, $path);
}

// Dispatch any post-merge commands
$post_merge_command = $required ? self::POST_MERGE_REQUIRED_CMD : self::POST_MERGE_OPTIONAL_CMD;
$this->composer->getEventDispatcher()->dispatchScript($post_merge_command, true);
}

/**
Expand Down

0 comments on commit e5f47b5

Please sign in to comment.