Use environment variables to define default values instead
parent
8d6f8a6f42
commit
a59f7399bf
|
@ -154,12 +154,11 @@ EOT
|
||||||
$git = $this->getGitConfig();
|
$git = $this->getGitConfig();
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
$formatter = $this->getHelperSet()->get('formatter');
|
$formatter = $this->getHelperSet()->get('formatter');
|
||||||
$config = Factory::createConfig($io);
|
|
||||||
$defaults = $config->get('defaults');
|
|
||||||
|
|
||||||
// initialize repos if configured
|
// initialize repos if configured
|
||||||
$repositories = $input->getOption('repository');
|
$repositories = $input->getOption('repository');
|
||||||
if ($repositories) {
|
if ($repositories) {
|
||||||
|
$config = Factory::createConfig($io);
|
||||||
$repos = array(new PlatformRepository);
|
$repos = array(new PlatformRepository);
|
||||||
foreach ($repositories as $repo) {
|
foreach ($repositories as $repo) {
|
||||||
$repos[] = RepositoryFactory::fromString($io, $config, $repo);
|
$repos[] = RepositoryFactory::fromString($io, $config, $repo);
|
||||||
|
@ -192,8 +191,8 @@ EOT
|
||||||
$name = basename($cwd);
|
$name = basename($cwd);
|
||||||
$name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
|
$name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
if ( isset($defaults['vendor']) ) {
|
if ( !empty($_SERVER['COMPOSER_DEFAULT_VENDOR']) ) {
|
||||||
$name = $defaults['vendor'] . '/' . $name;
|
$name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
|
||||||
} elseif (isset($git['github.user'])) {
|
} elseif (isset($git['github.user'])) {
|
||||||
$name = $git['github.user'] . '/' . $name;
|
$name = $git['github.user'] . '/' . $name;
|
||||||
} elseif (!empty($_SERVER['USERNAME'])) {
|
} elseif (!empty($_SERVER['USERNAME'])) {
|
||||||
|
@ -243,10 +242,20 @@ EOT
|
||||||
$input->setOption('description', $description);
|
$input->setOption('description', $description);
|
||||||
|
|
||||||
if (null === $author = $input->getOption('author')) {
|
if (null === $author = $input->getOption('author')) {
|
||||||
if ( isset($defaults['author']) && isset($defaults['author']['name']) && isset($defaults['author']['email']) ) {
|
if ( !empty($_SERVER['COMPOSER_DEFAULT_AUTHOR']) ) {
|
||||||
$author = sprintf('%s <%s>', $defaults['author']['name'], $defaults['author']['email']);
|
$author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
|
||||||
} elseif (isset($git['user.name']) && isset($git['user.email'])) {
|
} elseif ( isset($git['user.name']) ) {
|
||||||
$author = sprintf('%s <%s>', $git['user.name'], $git['user.email']);
|
$author_name = $git['user.name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($_SERVER['COMPOSER_DEFAULT_EMAIL']) ) {
|
||||||
|
$author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
|
||||||
|
} elseif ( isset($git['user.email']) ) {
|
||||||
|
$author_email = $git['user.email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($author_name) && isset($author_email)) {
|
||||||
|
$author = sprintf('%s <%s>', $author_name, $author_email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +306,8 @@ EOT
|
||||||
$input->setOption('type', $type);
|
$input->setOption('type', $type);
|
||||||
|
|
||||||
if (null === $license = $input->getOption('license')) {
|
if (null === $license = $input->getOption('license')) {
|
||||||
if ( isset($defaults['license']) ) {
|
if ( !empty($_SERVER['COMPOSER_DEFAULT_LICENSE']) ) {
|
||||||
$license = $defaults['license'];
|
$license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue