Skip to content

Commit

Permalink
Added warning to command when new Grav version is available (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig authored and rhukster committed Dec 7, 2016
1 parent 906c090 commit 7b2716d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions system/src/Grav/Console/Gpm/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Grav\Common\GPM\GPM;
use Grav\Common\GPM\Installer;
use Grav\Console\ConsoleCommand;
use Grav\Common\GPM\Upgrader;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -109,6 +110,22 @@ protected function configure()
*/
protected function serve()
{
$this->upgrader = new Upgrader($this->input->getOption('force'));
$local = $this->upgrader->getLocalVersion();
$remote = $this->upgrader->getRemoteVersion();
if ($local !== $remote) {
$this->output->writeln("<yellow>WARNING</yellow>: A new version of Grav is available. You should update Grav before updating plugins and themes. If you continue without updating Grav, some plugins or themes may stop working.");
$this->output->writeln("");
$questionHelper = $this->getHelper('question');
$question = new ConfirmationQuestion("Continue with the update process? [Y|n] ", true);
$answer = $questionHelper->ask($this->input, $this->output, $question);

if (!$answer) {
$this->output->writeln("<red>Update aborted. Exiting...</red>");
exit;
}
}

$this->gpm = new GPM($this->input->getOption('force'));

$this->all_yes = $this->input->getOption('all-yes');
Expand Down

0 comments on commit 7b2716d

Please sign in to comment.