diff --git a/src/Patches.php b/src/Patches.php index fbf6be6d..975ee2df 100644 --- a/src/Patches.php +++ b/src/Patches.php @@ -264,6 +264,11 @@ public function grabPatches() { * @throws \Exception */ public function postInstall(PackageEvent $event) { + + // Check if we should exit in failure. + $extra = $this->composer->getPackage()->getExtra(); + $exitOnFailure = getenv('COMPOSER_EXIT_ON_PATCH_FAILURE') || !empty($extra['composer-exit-on-patch-failure']); + // Get the package object for the current operation. $operation = $event->getOperation(); /** @var PackageInterface $package */ @@ -301,7 +306,7 @@ public function postInstall(PackageEvent $event) { } catch (\Exception $e) { $this->io->write(' Could not apply patch! Skipping. The error was: ' . $e->getMessage() . ''); - if (getenv('COMPOSER_EXIT_ON_PATCH_FAILURE') || !empty($extra['composer-exit-on-patch-failure'])) { + if ($exitOnFailure) { throw new \Exception("Cannot apply patch $description ($url)!"); } }