1
0
Fork 0

Make sure a constraint is provided with input requirements

pull/736/head
Jordi Boggiano 2012-05-26 14:51:06 +02:00
parent 27f8019dbd
commit 1443ea25f9
1 changed files with 9 additions and 0 deletions

View File

@ -260,6 +260,15 @@ EOT
if ($requires) {
foreach ($requires as $key => $requirement) {
$requires[$key] = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', $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)) {
$requires[$key] .= ' ' . $constraint;
}
}
if (false === strpos($requires[$key], ' ')) {
throw new \InvalidArgumentException('The requirement '.$requirement.' must contain a version constraint');
}
}
return $requires;