Skip to content

Commit

Permalink
Root package is also dumped in the current versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jan 25, 2016
1 parent 8406674 commit 9cb654d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/PackageVersions/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Package\Locker;
use Composer\Package\RootPackageInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
Expand Down Expand Up @@ -91,7 +92,7 @@ private static function generateVersionsClass(Composer $composer) : string
{
return sprintf(
self::$generatedClassTemplate,
var_export(iterator_to_array(self::getVersions($composer->getLocker())), true)
var_export(iterator_to_array(self::getVersions($composer->getLocker(), $composer->getPackage())), true)
);
}

Expand Down Expand Up @@ -127,13 +128,15 @@ private static function reDumpAutoloader(Composer $composer)
*
* @return string[]|\Generator
*/
private static function getVersions(Locker $locker) : \Generator
private static function getVersions(Locker $locker, RootPackageInterface $rootPackage) : \Generator
{
$lockData = $locker->getLockData();

foreach (array_merge($lockData['packages'], $lockData['packages-dev']) as $package) {
yield $package['name']
=> $package['version'] . '@' . $package['source']['reference'];
}

yield $rootPackage->getName() => $rootPackage->getVersion() . '@' . $rootPackage->getSourceReference();
}
}

0 comments on commit 9cb654d

Please sign in to comment.