Skip to content

Commit

Permalink
consolidation#497 Fix: Add Basic Self Update Functionality: add exit …
Browse files Browse the repository at this point in the history
…/ add return if no update
  • Loading branch information
amenk committed Aug 29, 2017
1 parent 70b7064 commit c98e521
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/SelfUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (Robo::VERSION == $latest) {
$output->writeln('No update available');
return;
}

$fs = new sfFilesystem();
Expand All @@ -116,6 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
unset($phar);
@rename($tempFilename, $localFilename);
$output->writeln('<info>Successfully updated ' . $programName . '</info>');
$this->_exit();
} catch (\Exception $e) {
@unlink($tempFilename);
if (! $e instanceof \UnexpectedValueException && ! $e instanceof \PharException) {
Expand All @@ -125,4 +127,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<error>Please re-run the self-update command to try again.</error>');
}
}

/**
* Stop execution
*
* This is a workaround to prevent warning of dispatcher after replacing
* the phar file.
*
* @return void
*/
protected function _exit()
{
exit;
}
}

0 comments on commit c98e521

Please sign in to comment.