From 35849ca227400dbf8ef266099e5e57c2433d1524 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 22 Oct 2011 22:23:45 +0200 Subject: [PATCH] Allow disabling of the default packagist repository in the main composer.json Example: { "repositories": { "packagist": false } } --- bin/composer | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/composer b/bin/composer index 2907c19de..7b2ee8da8 100755 --- a/bin/composer +++ b/bin/composer @@ -14,7 +14,6 @@ use Composer\Console\Application as ComposerApplication; // initialize repository manager $rm = new Repository\RepositoryManager(); $rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile('.composer/installed.json'))); -$rm->addRepository(new Repository\ComposerRepository('http://packagist.org')); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository'); @@ -31,8 +30,15 @@ $im->addInstaller(new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRep $im->addInstaller(new Installer\LibraryInstaller('vendor/bundles', $dm, $rm->getLocalRepository(), 'symfony-bundle')); // load package -$loader = new Package\Loader\JsonLoader(); -$package = $loader->load(new JsonFile('composer.json')); +$loader = new Package\Loader\ArrayLoader($rm); +$file = new JsonFile('composer.json'); +$packageConfig = $file->read(); +$package = $loader->load($packageConfig); + +// load default repository unless it's explicitly disabled +if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) { + $rm->addRepository(new Repository\ComposerRepository('http://packagist.org')); +} // init locker $locker = new Package\Locker(new JsonFile('composer.lock'), $rm);