From ff2c3e96146843db112824fce336e1a65bf1cd39 Mon Sep 17 00:00:00 2001 From: gertjan Date: Tue, 14 Mar 2017 15:37:42 +0100 Subject: [PATCH] Copy files in all installed packages --- .../Plugin/Filescopier/ScriptHandler.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Sasedev/Composer/Plugin/Filescopier/ScriptHandler.php b/src/Sasedev/Composer/Plugin/Filescopier/ScriptHandler.php index 0058161..f8b056c 100644 --- a/src/Sasedev/Composer/Plugin/Filescopier/ScriptHandler.php +++ b/src/Sasedev/Composer/Plugin/Filescopier/ScriptHandler.php @@ -5,6 +5,7 @@ use Composer\Composer; use Composer\EventDispatcher\EventSubscriberInterface; use Composer\IO\IOInterface; +use Composer\Package\PackageInterface; use Composer\Plugin\PluginInterface; use Composer\Script\Event; @@ -77,13 +78,24 @@ public function onPostCmd(Event $event) public static function buildParameters(Event $event) { - $IO = $event->getIO(); - $composer = $event->getComposer(); + $installedPackages = $event->getComposer() + ->getRepositoryManager() + ->getLocalRepository() + ->getCanonicalPackages(); + foreach ($installedPackages as $package) { + self::copyFiles($event, $package); + } + + } - $extras = $composer->getPackage()->getExtra(); - if (!isset($extras['filescopier'])) { - $IO->write('The parameter handler needs to be configured through the extra.filescopier setting.'); - } else { + /** + * @param \Composer\Script\Event $event + * @param \Composer\Package\PackageInterface $package + */ + protected static function copyFiles(Event $event, PackageInterface $package) + { + $extras = $package->getExtra(); + if (isset($extras['filescopier'])) { $configs = $extras['filescopier']; if (!is_array($configs)) { throw new \InvalidArgumentException('The extra.filescopier setting must be an array or a configuration object.'); @@ -105,7 +117,6 @@ public static function buildParameters(Event $event) $processor->processCopy($config); } } - } } \ No newline at end of file