Add info about conf file loading to debug output

main
Jordi Boggiano 10 years ago
parent 615402c861
commit 959cc4d63c

@ -103,7 +103,7 @@ EOT
throw new \RuntimeException('--file and --global can not be combined'); 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 // Get the local composer.json, global config.json, or if the user
// passed in a file to use // passed in a file to use

@ -83,7 +83,7 @@ class Factory
/** /**
* @return Config * @return Config
*/ */
public static function createConfig() public static function createConfig(IOInterface $io = null)
{ {
// determine home and cache dirs // determine home and cache dirs
$home = self::getHomeDir(); $home = self::getHomeDir();
@ -109,6 +109,9 @@ class Factory
// load global config // load global config
$file = new JsonFile($home.'/config.json'); $file = new JsonFile($home.'/config.json');
if ($file->exists()) { if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->write('Loading config file ' . $file->getPath());
}
$config->merge($file->read()); $config->merge($file->read());
} }
$config->setConfigSource(new JsonConfigSource($file)); $config->setConfigSource(new JsonConfigSource($file));
@ -116,6 +119,9 @@ class Factory
// load global auth file // load global auth file
$file = new JsonFile($config->get('home').'/auth.json'); $file = new JsonFile($config->get('home').'/auth.json');
if ($file->exists()) { if ($file->exists()) {
if ($io && $io->isDebug()) {
$io->write('Loading config file ' . $file->getPath());
}
$config->merge(array('config' => $file->read())); $config->merge(array('config' => $file->read()));
} }
$config->setAuthConfigSource(new JsonConfigSource($file, true)); $config->setAuthConfigSource(new JsonConfigSource($file, true));
@ -173,7 +179,7 @@ class Factory
$repos = array(); $repos = array();
if (!$config) { if (!$config) {
$config = static::createConfig(); $config = static::createConfig($io);
} }
if (!$rm) { if (!$rm) {
if (!$io) { if (!$io) {
@ -237,11 +243,17 @@ class Factory
} }
// Load config and override with local config/auth config // Load config and override with local config/auth config
$config = static::createConfig(); $config = static::createConfig($io);
$config->merge($localConfig); $config->merge($localConfig);
if (isset($composerFile)) { if (isset($composerFile)) {
if ($io && $io->isDebug()) {
$io->write('Loading config file ' . $composerFile);
}
$localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json'); $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
if ($localAuthFile->exists()) { if ($localAuthFile->exists()) {
if ($io && $io->isDebug()) {
$io->write('Loading config file ' . $localAuthFile->getPath());
}
$config->merge(array('config' => $localAuthFile->read())); $config->merge(array('config' => $localAuthFile->read()));
$config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true)); $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
} }

@ -21,7 +21,7 @@ use Composer\IO\IOInterface;
class FactoryMock extends Factory class FactoryMock extends Factory
{ {
public static function createConfig() public static function createConfig(IOInterface $io = null)
{ {
$config = new Config(); $config = new Config();

Loading…
Cancel
Save