Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit dd59a04

Browse files
committed
bug #276 Fixed some issues for the self-update command (smatyas)
This PR was merged into the 1.0-dev branch. Discussion ---------- Fixed some issues for the self-update command Currently, the `self-update` command does not return an alerting enough exit message or status code on permission errors. I saw in the code that it was intended, but it did not work well enough. This PR fixes this issue by modifying the thrown exception type in certain cases, and by making the fallback exception to return error code 1, and by coloring the rollback message. Before: ![image](https://cloud.githubusercontent.com/assets/534550/18207370/447a9004-712b-11e6-99f9-78bc05529dc9.png) After: ![image](https://cloud.githubusercontent.com/assets/534550/18207382/5530b4be-712b-11e6-9763-e18fe4fdf6cf.png) Commits ------- ab6cce2 Fixed some issues for the self-update command: added coloring to the rollback message, set return code at general exception handling, fixed an undefined variable notice.
2 parents 747d612 + ab6cce2 commit dd59a04

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Installer/DownloadCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ protected function getExecutedCommand()
520520
}
521521

522522
$commandName = $this->getName();
523+
$commandArguments = '';
523524

524525
if ('new' === $commandName) {
525526
$commandArguments = sprintf('%s %s', $this->projectName, ('latest' !== $this->version) ? $this->version : '');

src/Symfony/Installer/SelfUpdateCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
136136
if ($this->output->isVeryVerbose()) {
137137
$this->output->writeln($e->getMessage());
138138
}
139+
140+
return 1;
139141
}
140142
}
141143

@@ -148,11 +150,11 @@ private function downloadNewVersion()
148150
{
149151
// check for permissions in local filesystem before start downloading files
150152
if (!is_writable($this->currentInstallerFile)) {
151-
throw new \RuntimeException('Symfony Installer update failed: the "'.$this->currentInstallerFile.'" file could not be written');
153+
throw new IOException('Symfony Installer update failed: the "'.$this->currentInstallerFile.'" file could not be written');
152154
}
153155

154156
if (!is_writable($this->tempDir)) {
155-
throw new \RuntimeException('Symfony Installer update failed: the "'.$this->tempDir.'" directory used to download files temporarily could not be written');
157+
throw new IOException('Symfony Installer update failed: the "'.$this->tempDir.'" directory used to download files temporarily could not be written');
156158
}
157159

158160
if (false === $newInstaller = $this->getUrlContents($this->remoteInstallerFile)) {
@@ -225,7 +227,7 @@ private function rollback()
225227
{
226228
$this->output->writeln(array(
227229
'',
228-
'There was an error while updating the installer.',
230+
'<error>There was an error while updating the installer.</error>',
229231
'The previous Symfony Installer version has been restored.',
230232
'',
231233
));

0 commit comments

Comments
 (0)