Rollback changes in case the installer fails in remove/require commands, fixes #3464
parent
b9a3ef73c0
commit
823266407f
|
@ -116,11 +116,19 @@ EOT
|
|||
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
|
||||
;
|
||||
|
||||
$status = $install->run();
|
||||
$exception = null;
|
||||
try {
|
||||
$status = $install->run();
|
||||
} catch (\Exception $exception) {
|
||||
$status = 1;
|
||||
}
|
||||
if ($status !== 0) {
|
||||
$io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
|
||||
file_put_contents($jsonFile->getPath(), $composerBackup);
|
||||
}
|
||||
if ($exception) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
|
|
@ -165,7 +165,12 @@ EOT
|
|||
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
|
||||
;
|
||||
|
||||
$status = $install->run();
|
||||
$exception = null;
|
||||
try {
|
||||
$status = $install->run();
|
||||
} catch (\Exception $exception) {
|
||||
$status = 1;
|
||||
}
|
||||
if ($status !== 0) {
|
||||
if ($newlyCreated) {
|
||||
$io->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>');
|
||||
|
@ -175,6 +180,9 @@ EOT
|
|||
file_put_contents($json->getPath(), $composerBackup);
|
||||
}
|
||||
}
|
||||
if ($exception) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue