Skip to content

Commit

Permalink
Copy files in all installed packages
Browse files Browse the repository at this point in the history
  • Loading branch information
gjnedbase committed Mar 14, 2017
1 parent 0cb2430 commit ff2c3e9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Sasedev/Composer/Plugin/Filescopier/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.');
Expand All @@ -105,7 +117,6 @@ public static function buildParameters(Event $event)
$processor->processCopy($config);
}
}

}

}

0 comments on commit ff2c3e9

Please sign in to comment.