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}..."