Move duplicate key parsing from bootstrap to validate/diagnose to reduce bootstrap time a bit
parent
9a42f69a99
commit
27a449eaf7
|
@ -316,13 +316,6 @@ class Factory
|
|||
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
|
||||
throw new JsonValidationException($message);
|
||||
}
|
||||
$jsonParser = new JsonParser;
|
||||
try {
|
||||
$jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
|
||||
} catch (DuplicateKeyException $e) {
|
||||
$details = $e->getDetails();
|
||||
$io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
|
||||
}
|
||||
|
||||
$localConfig = $file->read();
|
||||
$localConfigSource = $file->getPath();
|
||||
|
|
|
@ -20,6 +20,8 @@ use Composer\IO\IOInterface;
|
|||
use Composer\Json\JsonFile;
|
||||
use Composer\Pcre\Preg;
|
||||
use Composer\Spdx\SpdxLicenses;
|
||||
use Seld\JsonLint\DuplicateKeyException;
|
||||
use Seld\JsonLint\JsonParser;
|
||||
|
||||
/**
|
||||
* Validates a composer configuration.
|
||||
|
@ -77,6 +79,14 @@ class ConfigValidator
|
|||
return array($errors, $publishErrors, $warnings);
|
||||
}
|
||||
|
||||
$jsonParser = new JsonParser();
|
||||
try {
|
||||
$jsonParser->parse(file_get_contents($file), JsonParser::DETECT_KEY_CONFLICTS);
|
||||
} catch (DuplicateKeyException $e) {
|
||||
$details = $e->getDetails();
|
||||
$warnings[] = 'Key '.$details['key'].' is a duplicate in '.$file.' at line '.$details['line'];
|
||||
}
|
||||
|
||||
// validate actual data
|
||||
if (empty($manifest['license'])) {
|
||||
$warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
|
||||
|
|
Loading…
Reference in New Issue