From 18a80ac824ccacde593254ff787e93beeb3fb5b8 Mon Sep 17 00:00:00 2001 From: Wout Gevaert Date: Mon, 31 Oct 2022 09:32:26 +0100 Subject: [PATCH] Don't include composer files already required by root package this solves several issues --- src/ExtraPackage.php | 10 ++++++++++ src/MergePlugin.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/ExtraPackage.php b/src/ExtraPackage.php index 2471cb0..d1c2d30 100644 --- a/src/ExtraPackage.php +++ b/src/ExtraPackage.php @@ -114,6 +114,16 @@ public function getMergedRequirements() return array_keys($this->mergedRequirements); } + /** + * Get the name of this package + * + * @return string + */ + public function getName() + { + return $this->json['name']; + } + /** * Read the contents of a composer.json style file into an array. * diff --git a/src/MergePlugin.php b/src/MergePlugin.php index a9af5b6..767422a 100644 --- a/src/MergePlugin.php +++ b/src/MergePlugin.php @@ -270,6 +270,13 @@ protected function mergeFile(RootPackageInterface $root, $path) $package = new ExtraPackage($path, $this->composer, $this->logger); + if (isset($root->getRequires()[$package->getName()])) { + $this->logger->info( + "Ignoring composer json already required by root: {$package->getName()}" + ); + return; + } + if (isset($this->loadedNoDev[$path])) { $this->logger->info( "Loading -dev sections of {$path}..."