1
0
Fork 0

Fix normalization in init command with --no-interaction and --require

When calling `composer init --no-interaction --require foo/bar:dev-master` it
would fail because in non-interactive mode it would only split on space.
pull/739/head
Igor Wiedler 2012-05-28 02:37:33 +02:00
parent 242323cba4
commit a0c90bad0f
1 changed files with 7 additions and 1 deletions

View File

@ -259,7 +259,7 @@ EOT
if ($requires) {
foreach ($requires as $key => $requirement) {
$requires[$key] = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', $requirement);
$requires[$key] = $this->normalizeRequirement($requirement);
if (false === strpos($requires[$key], ' ') && $input->isInteractive()) {
$question = $dialog->getQuestion('Please provide a version constraint for the '.$requirement.' requirement');
if ($constraint = $dialog->ask($output, $question)) {
@ -328,6 +328,7 @@ EOT
{
$requires = array();
foreach ($requirements as $requirement) {
$requirement = $this->normalizeRequirement($requirement);
list($packageName, $packageVersion) = explode(" ", $requirement, 2);
$requires[$packageName] = $packageVersion;
@ -336,6 +337,11 @@ EOT
return empty($requires) ? new \stdClass : $requires;
}
protected function normalizeRequirement($requirement)
{
return preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', $requirement);
}
protected function getGitConfig()
{
if (null !== $this->gitConfig) {