Skip to content

Commit

Permalink
Run "composer update" for subpackages when updating main package
Browse files Browse the repository at this point in the history
Refs #26.
  • Loading branch information
franzliedke committed Sep 17, 2015
1 parent 5d66fb6 commit 6641995
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Composer/StudioPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Studio\Config\Config;
use Studio\Config\FileStorage;
use Symfony\Component\Finder\Finder;
use Studio\Shell\Shell;

class StudioPlugin implements PluginInterface, EventSubscriberInterface
{
Expand All @@ -24,6 +25,7 @@ public static function getSubscribedEvents()
{
return [
ScriptEvents::POST_AUTOLOAD_DUMP => 'dumpAutoload',
ScriptEvents::POST_UPDATE_CMD => 'update',
];
}

Expand All @@ -39,6 +41,21 @@ public function dumpAutoload(Event $event)
}
}

public function update(Event $event)
{
$path = $event->getComposer()->getPackage()->getTargetDir();
$studioFile = "{$path}studio.json";

$config = $this->getConfig($studioFile);
if ($config->hasPackages()) {
$packages = $config->getPackages();

foreach ($packages as $directory) {
Shell::run('composer update', $directory);
}
}
}

/**
* Instantiate and return the config object.
*
Expand Down

0 comments on commit 6641995

Please sign in to comment.