1
0
Fork 0

Avoid requirement on composer.json to search for requirements

pull/303/merge
Jordi Boggiano 2012-02-16 20:39:59 +01:00
parent 23aade21f0
commit f48cfb4fdf
1 changed files with 17 additions and 11 deletions

View File

@ -13,6 +13,9 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\ComposerRepository;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -21,10 +24,12 @@ use Symfony\Component\Process\ExecutableFinder;
/** /**
* @author Justin Rainbow <justin.rainbow@gmail.com> * @author Justin Rainbow <justin.rainbow@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class InitCommand extends Command class InitCommand extends Command
{ {
private $gitConfig; private $gitConfig;
private $repos;
public function parseAuthorString($author) public function parseAuthorString($author)
{ {
@ -214,22 +219,23 @@ EOT
protected function findPackages($name) protected function findPackages($name)
{ {
$composer = $this->getComposer();
$packages = array(); $packages = array();
// create local repo, this contains all packages that are installed in the local project // init repos
$localRepo = $composer->getRepositoryManager()->getLocalRepository(); if (!$this->repos) {
$this->repos = new CompositeRepository(array(
new PlatformRepository,
new ComposerRepository(array('url' => 'http://packagist.org'))
));
}
$token = strtolower($name); $token = strtolower($name);
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) { foreach ($this->repos->getPackages() as $package) {
foreach ($repository->getPackages() as $package) { if (false === ($pos = strpos($package->getName(), $token))) {
if (false === ($pos = strpos($package->getName(), $token))) { continue;
continue;
}
$packages[] = $package;
} }
$packages[] = $package;
} }
return $packages; return $packages;