diff --git a/src/MergePlugin.php b/src/MergePlugin.php index a9af5b6..e235417 100644 --- a/src/MergePlugin.php +++ b/src/MergePlugin.php @@ -20,6 +20,7 @@ use Composer\Installer\PackageEvents; use Composer\IO\IOInterface; use Composer\Package\RootPackageInterface; +use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; use Composer\Plugin\PluginInterface; use Composer\Script\Event as ScriptEvent; @@ -155,6 +156,8 @@ public static function getSubscribedEvents() return [ PluginEvents::INIT => ['onInit', self::CALLBACK_PRIORITY], + PluginEvents::COMMAND => + ['onCommand', self::CALLBACK_PRIORITY], PackageEvents::POST_PACKAGE_INSTALL => ['onPostPackageInstall', self::CALLBACK_PRIORITY], ScriptEvents::POST_INSTALL_CMD => @@ -197,6 +200,21 @@ public function onInit(BaseEvent $event) $this->mergeFiles($this->state->getRequires(), true); } + /** + * @param \Composer\Plugin\CommandEvent $event + * + * @return void + */ + public function onCommand(CommandEvent $event) + { + if ($event->getCommandName() == 'depends') { + // This command needs to know about dev dependencies. + $this->state->setDevMode(true); + $this->mergeFiles($this->state->getIncludes()); + $this->mergeFiles($this->state->getRequires(), true); + } + } + /** * Handle an event callback for an install, update or dump command by * checking for "merge-plugin" in the "extra" data and merging package diff --git a/tests/phpunit/MergePluginTest.php b/tests/phpunit/MergePluginTest.php index 8fff0ea..13290fd 100644 --- a/tests/phpunit/MergePluginTest.php +++ b/tests/phpunit/MergePluginTest.php @@ -81,9 +81,10 @@ public function testSubscribedEvents() { $subscriptions = MergePlugin::getSubscribedEvents(); - $this->assertCount(7, $subscriptions); + $this->assertCount(8, $subscriptions); $this->assertArrayHasKey(PluginEvents::INIT, $subscriptions); + $this->assertArrayHasKey(PluginEvents::COMMAND, $subscriptions); $this->assertArrayHasKey(ScriptEvents::PRE_INSTALL_CMD, $subscriptions); $this->assertArrayHasKey(ScriptEvents::PRE_UPDATE_CMD, $subscriptions); $this->assertArrayHasKey(ScriptEvents::PRE_AUTOLOAD_DUMP, $subscriptions);