diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php
index 759103c8a..b74076302 100644
--- a/src/Composer/Command/RemoveCommand.php
+++ b/src/Composer/Command/RemoveCommand.php
@@ -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".'Removal failed, reverting '.$file.' to its original content.');
file_put_contents($jsonFile->getPath(), $composerBackup);
}
+ if ($exception) {
+ throw $exception;
+ }
return $status;
}
diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php
index 65294c44b..f3780d8de 100644
--- a/src/Composer/Command/RequireCommand.php
+++ b/src/Composer/Command/RequireCommand.php
@@ -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".'Installation failed, deleting '.$file.'.');
@@ -175,6 +180,9 @@ EOT
file_put_contents($json->getPath(), $composerBackup);
}
}
+ if ($exception) {
+ throw $exception;
+ }
return $status;
}