Add --no-check-publish option to "composer validate"
This is useful when you want to use composer to manage dependencies, but don't actually want your project to be installable as a composer package. Any issues that would prevent publishing are still shown, but as a warning instead of an error.pull/3804/head
parent
d5feea83b6
commit
05e196893b
|
@ -37,6 +37,7 @@ class ValidateCommand extends Command
|
|||
->setDescription('Validates a composer.json')
|
||||
->setDefinition(array(
|
||||
new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not make a complete validation'),
|
||||
new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
|
||||
new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file', './composer.json')
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
|
@ -69,6 +70,7 @@ EOT
|
|||
|
||||
$validator = new ConfigValidator($this->getIO());
|
||||
$checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
|
||||
$checkPublish = !$input->getOption('no-check-publish');
|
||||
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
|
||||
|
||||
// output errors/warnings
|
||||
|
@ -86,16 +88,23 @@ EOT
|
|||
}
|
||||
|
||||
$messages = array(
|
||||
'error' => array_merge($errors, $publishErrors),
|
||||
'error' => $errors,
|
||||
'warning' => $warnings,
|
||||
);
|
||||
|
||||
// If checking publish errors, display them errors, otherwise just show them as warnings
|
||||
if ($checkPublish) {
|
||||
$messages['error'] = array_merge($messages['error'], $publishErrors);
|
||||
} else {
|
||||
$messages['warning'] = array_merge($messages['warning'], $publishErrors);
|
||||
}
|
||||
|
||||
foreach ($messages as $style => $msgs) {
|
||||
foreach ($msgs as $msg) {
|
||||
$this->getIO()->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors || $publishErrors ? 1 : 0;
|
||||
return $errors || ($publishErrors && $checkPublish) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue