diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 214f0341f..67a2f70a8 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -103,7 +103,7 @@ EOT throw new \RuntimeException('--file and --global can not be combined'); } - $this->config = Factory::createConfig(); + $this->config = Factory::createConfig($this->getIO()); // Get the local composer.json, global config.json, or if the user // passed in a file to use diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 6bfdaf98b..099ad37ea 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -83,7 +83,7 @@ class Factory /** * @return Config */ - public static function createConfig() + public static function createConfig(IOInterface $io = null) { // determine home and cache dirs $home = self::getHomeDir(); @@ -109,6 +109,9 @@ class Factory // load global config $file = new JsonFile($home.'/config.json'); if ($file->exists()) { + if ($io && $io->isDebug()) { + $io->write('Loading config file ' . $file->getPath()); + } $config->merge($file->read()); } $config->setConfigSource(new JsonConfigSource($file)); @@ -116,6 +119,9 @@ class Factory // load global auth file $file = new JsonFile($config->get('home').'/auth.json'); if ($file->exists()) { + if ($io && $io->isDebug()) { + $io->write('Loading config file ' . $file->getPath()); + } $config->merge(array('config' => $file->read())); } $config->setAuthConfigSource(new JsonConfigSource($file, true)); @@ -173,7 +179,7 @@ class Factory $repos = array(); if (!$config) { - $config = static::createConfig(); + $config = static::createConfig($io); } if (!$rm) { if (!$io) { @@ -237,11 +243,17 @@ class Factory } // Load config and override with local config/auth config - $config = static::createConfig(); + $config = static::createConfig($io); $config->merge($localConfig); if (isset($composerFile)) { + if ($io && $io->isDebug()) { + $io->write('Loading config file ' . $composerFile); + } $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json'); if ($localAuthFile->exists()) { + if ($io && $io->isDebug()) { + $io->write('Loading config file ' . $localAuthFile->getPath()); + } $config->merge(array('config' => $localAuthFile->read())); $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true)); } diff --git a/tests/Composer/Test/Mock/FactoryMock.php b/tests/Composer/Test/Mock/FactoryMock.php index 11b266590..75d2a23bb 100644 --- a/tests/Composer/Test/Mock/FactoryMock.php +++ b/tests/Composer/Test/Mock/FactoryMock.php @@ -21,7 +21,7 @@ use Composer\IO\IOInterface; class FactoryMock extends Factory { - public static function createConfig() + public static function createConfig(IOInterface $io = null) { $config = new Config();