From e7027612846eaa532ffa50a57384836c019d71e2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 14 Apr 2012 12:07:49 +0200 Subject: [PATCH] Output suggested packages after package installation --- src/Composer/Installer.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index bd8b15827..e459c94ca 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -273,10 +273,23 @@ class Installer $this->io->write('Nothing to install or update'); } + $suggestedPackages = array(); foreach ($operations as $operation) { if ($this->verbose) { $this->io->write((string) $operation); } + + // collect suggestions + if ('install' === $operation->getJobType()) { + foreach ($operation->getPackage()->getSuggests() as $target => $reason) { + $suggestedPackages[] = array( + 'source' => $operation->getPackage()->getPrettyName(), + 'target' => $target, + 'reason' => $reason, + ); + } + } + if (!$this->dryRun) { $this->eventDispatcher->dispatchPackageEvent(constant('Composer\Script\ScriptEvents::PRE_PACKAGE_'.strtoupper($operation->getJobType())), $operation); @@ -306,15 +319,20 @@ class Installer } } + // dump suggestions + foreach ($suggestedPackages as $suggestion) { + $this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')'); + } + if (!$this->dryRun) { + // write lock if ($this->update || !$this->locker->isLocked()) { if ($this->locker->setLockData($localRepo->getPackages(), $aliases)) { $this->io->write('Writing lock file'); } } - $localRepo->write(); - + // write autoloader $this->io->write('Generating autoload files'); $generator = new AutoloadGenerator; $generator->dump($localRepo, $this->package, $this->installationManager, $this->installationManager->getVendorPath().'/.composer');