Skip to content

Commit

Permalink
Fixes #3148: Frivolous composer notices. (#3701)
Browse files Browse the repository at this point in the history
* Fixes #3148: Frivolous composer notices.

* Fixed code style.

* Use native plugin instead of script.
  • Loading branch information
danepowell authored Jun 6, 2019
1 parent b23164c commit d5146e1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function activate(Composer $composer, IOInterface $io) {
*/
public static function getSubscribedEvents() {
return array(
ScriptEvents::POST_AUTOLOAD_DUMP => "onPostAutoloadDump",
PackageEvents::POST_PACKAGE_INSTALL => "onPostPackageEvent",
PackageEvents::POST_PACKAGE_UPDATE => "onPostPackageEvent",
ScriptEvents::POST_UPDATE_CMD => array(
Expand All @@ -92,6 +93,25 @@ public static function getSubscribedEvents() {
);
}

/**
* Modify vendor/composer/installed.json so that composer/installers is first.
*
* @param \Composer\Script\Event $event
*/
public static function onPostAutoloadDump(Event $event) {
$composer = $event->getComposer();
$vendor_dir = $composer->getConfig()->get('vendor-dir');
$installed_json = realpath($vendor_dir) . "/composer/installed.json";
$installed = json_decode(file_get_contents($installed_json));
foreach ($installed as $key => $package) {
if ($package->name == 'composer/installers') {
unset($installed[$key]);
array_unshift($installed, $package);
}
}
file_put_contents($installed_json, json_encode($installed, 448));
}

/**
* Marks blt to be processed after an install or update command.
*
Expand Down

0 comments on commit d5146e1

Please sign in to comment.