From 28599b22f6df0953ba24d6a2f8e8f29cf72814f7 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sun, 21 Feb 2016 12:14:11 -0500 Subject: [PATCH 1/4] Add the --root-require option to the update command --- src/Composer/Command/UpdateCommand.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 118a04fa1..78dc1f2d8 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -56,6 +56,7 @@ class UpdateCommand extends Command 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('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(<<update command reads the composer.json file from the @@ -101,6 +102,21 @@ EOT $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')); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output); From 63cb357a6eb3de62add6d644192842ee67fa5877 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sun, 21 Feb 2016 12:18:03 -0500 Subject: [PATCH 2/4] Clean up coding standards --- src/Composer/Command/UpdateCommand.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 78dc1f2d8..c3fcc4c40 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -103,18 +103,17 @@ EOT } 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); - } + $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; - } + if (!empty($packages)) { + $packages = array_intersect($packages, $require); + } else { + $packages = $require; + } } $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); From 93b246e68107426e75e9b3cf20db54fff58268e7 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 22 Feb 2016 22:05:24 -0500 Subject: [PATCH 3/4] Use single quotes insted of double and fix typo --- src/Composer/Command/UpdateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index c3fcc4c40..a8094882a 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -56,7 +56,7 @@ class UpdateCommand extends Command 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('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."), + new InputOption('root-require', null, InputOption::VALUE_NONE, 'Only update dependencies that are listed in the root package\'s composer.json file.'), )) ->setHelp(<<update command reads the composer.json file from the From df8675f6c3ab52ecf4d42297dee28ce7024d5627 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Tue, 23 Feb 2016 06:33:03 -0500 Subject: [PATCH 4/4] Fix variable name. --- src/Composer/Command/UpdateCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index a8094882a..b40fea31c 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -105,8 +105,8 @@ EOT 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); + $requireDev = array_keys($composer->getPackage()->getDevRequires()); + $require = array_merge($require, $requireDev); } if (!empty($packages)) {