Add the --root-require option to the update command
parent
4c0e163977
commit
28599b22f6
|
@ -56,6 +56,7 @@ class UpdateCommand extends Command
|
||||||
new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
|
new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
|
||||||
new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
|
new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
|
||||||
new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
|
new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
|
||||||
|
new InputOption('root-require', null, InputOption::VALUE_NONE, "Only update dependencies that are listed in the root package's compoer.json file."),
|
||||||
))
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
The <info>update</info> command reads the composer.json file from the
|
The <info>update</info> command reads the composer.json file from the
|
||||||
|
@ -101,6 +102,21 @@ EOT
|
||||||
$packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
|
$packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('root-require')) {
|
||||||
|
$require = array_keys($composer->getPackage()->getRequires());
|
||||||
|
if (!$input->getOption('no-dev')) {
|
||||||
|
$require_dev = array_keys($composer->getPackage()->getDevRequires());
|
||||||
|
$require = array_merge($require, $require_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($packages)) {
|
||||||
|
$packages = array_intersect($packages, $require);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$packages = $require;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
||||||
|
|
Loading…
Reference in New Issue