1
0
Fork 0

Merge pull request #2952 from jeromemacias/config_validator_array_loader_flags

Add --no-check-all option to composer validate command
pull/2963/head
Jordi Boggiano 2014-05-01 17:40:28 +02:00
commit e87bc894da
3 changed files with 13 additions and 4 deletions

View File

@ -248,6 +248,10 @@ You should always run the `validate` command before you commit your
$ php composer.phar validate $ php composer.phar validate
### Options
* **--no-check-all:** Wether or not composer do a complete validation.
## status ## status
If you often need to modify the code of your dependencies and they are If you often need to modify the code of your dependencies and they are

View File

@ -12,9 +12,11 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Package\Loader\ValidatingArrayLoader;
use Composer\Util\ConfigValidator; use Composer\Util\ConfigValidator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
/** /**
@ -34,6 +36,7 @@ class ValidateCommand extends Command
->setName('validate') ->setName('validate')
->setDescription('Validates a composer.json') ->setDescription('Validates a composer.json')
->setDefinition(array( ->setDefinition(array(
new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not make a complete validation'),
new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file', './composer.json') new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file', './composer.json')
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
@ -65,7 +68,8 @@ EOT
} }
$validator = new ConfigValidator($this->getIO()); $validator = new ConfigValidator($this->getIO());
list($errors, $publishErrors, $warnings) = $validator->validate($file); $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
// output errors/warnings // output errors/warnings
if (!$errors && !$publishErrors && !$warnings) { if (!$errors && !$publishErrors && !$warnings) {

View File

@ -38,10 +38,11 @@ class ConfigValidator
* Validates the config, and returns the result. * Validates the config, and returns the result.
* *
* @param string $file The path to the file * @param string $file The path to the file
* @param integer $arrayLoaderValidationFlags Flags for ArrayLoader validation
* *
* @return array a triple containing the errors, publishable errors, and warnings * @return array a triple containing the errors, publishable errors, and warnings
*/ */
public function validate($file) public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL)
{ {
$errors = array(); $errors = array();
$publishErrors = array(); $publishErrors = array();
@ -119,7 +120,7 @@ class ConfigValidator
} }
try { try {
$loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, ValidatingArrayLoader::CHECK_ALL); $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
if (!isset($manifest['version'])) { if (!isset($manifest['version'])) {
$manifest['version'] = '1.0.0'; $manifest['version'] = '1.0.0';
} }