1
0
Fork 0

Normalize minimum-stability `rc` to `RC` in `InitCommand`

A `minimum-stability` of `rc` is valid according to
`composer-schema.json` and works fine with install and update and
generally in version comparisons, because it's normalized to `RC`.

This commit makes it work in `InitCommand` and `RequireCommand` too.
pull/8534/head
Patrick Weyck 2020-01-14 15:39:11 +01:00
parent b9d00153d9
commit 7d7e3d594b
1 changed files with 3 additions and 2 deletions

View File

@ -16,6 +16,7 @@ use Composer\DependencyResolver\Pool;
use Composer\Factory;
use Composer\Json\JsonFile;
use Composer\Package\BasePackage;
use Composer\Package\Package;
use Composer\Package\Version\VersionParser;
use Composer\Package\Version\VersionSelector;
use Composer\Repository\CompositeRepository;
@ -702,13 +703,13 @@ EOT
private function getMinimumStability(InputInterface $input)
{
if ($input->hasOption('stability')) {
return $input->getOption('stability') ?: 'stable';
return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
}
$file = Factory::getComposerFile();
if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
if (!empty($composer['minimum-stability'])) {
return $composer['minimum-stability'];
return VersionParser::normalizeStability($composer['minimum-stability']);
}
}