diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index aa7213060..0772e2de4 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -154,11 +154,12 @@ EOT $git = $this->getGitConfig(); $io = $this->getIO(); $formatter = $this->getHelperSet()->get('formatter'); - + $config = Factory::createConfig($io); + $defaults = $config->get('defaults'); + // initialize repos if configured $repositories = $input->getOption('repository'); if ($repositories) { - $config = Factory::createConfig($io); $repos = array(new PlatformRepository); foreach ($repositories as $repo) { $repos[] = RepositoryFactory::fromString($io, $config, $repo); @@ -191,7 +192,9 @@ EOT $name = basename($cwd); $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name); $name = strtolower($name); - if (isset($git['github.user'])) { + if ( isset($defaults['vendor']) ) { + $name = $defaults['vendor'] . '/' . $name; + } elseif (isset($git['github.user'])) { $name = $git['github.user'] . '/' . $name; } elseif (!empty($_SERVER['USERNAME'])) { $name = $_SERVER['USERNAME'] . '/' . $name; @@ -240,7 +243,9 @@ EOT $input->setOption('description', $description); if (null === $author = $input->getOption('author')) { - if (isset($git['user.name']) && isset($git['user.email'])) { + if ( isset($defaults['author']) && isset($defaults['author']['name']) && isset($defaults['author']['email']) ) { + $author = sprintf('%s <%s>', $defaults['author']['name'], $defaults['author']['email']); + } elseif (isset($git['user.name']) && isset($git['user.email'])) { $author = sprintf('%s <%s>', $git['user.name'], $git['user.email']); } } @@ -291,7 +296,12 @@ EOT ); $input->setOption('type', $type); - $license = $input->getOption('license') ?: false; + if (null === $license = $input->getOption('license')) { + if ( isset($defaults['license']) ) { + $license = $defaults['license']; + } + } + $license = $io->ask( 'License ['.$license.']: ', $license