Browse Source

Fail if no repository was found

Dennis Birkholz 9 years ago
parent
commit
c06edd61e4
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/Composer/Repository/PathRepository.php

+ 7 - 0
src/Composer/Repository/PathRepository.php

@@ -101,12 +101,15 @@ class PathRepository extends ArrayRepository
     {
         parent::initialize();
 
+        $foundPackage = false;
+
         foreach ($this->getPaths() as $path) {
             $composerFilePath = $path.'composer.json';
             if (!file_exists($composerFilePath)) {
                 continue;
             }
 
+            $foundPackage = true;
             $json = file_get_contents($composerFilePath);
             $package = JsonFile::parseJson($json, $composerFilePath);
             $package['dist'] = array(
@@ -125,6 +128,10 @@ class PathRepository extends ArrayRepository
             $package = $this->loader->load($package);
             $this->addPackage($package);
         }
+
+        if (!$foundPackage) {
+            throw new \RuntimeException(sprintf('No `composer.json` file found in any path repository in "%s"', $this->url));
+        }
     }
 
     /**