Skip to content

Commit

Permalink
Exit on patch failure should use composer extra, not localPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl DeBisschop authored and cweagans committed Nov 9, 2017
1 parent f773888 commit d011661
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -301,7 +306,7 @@ public function postInstall(PackageEvent $event) {
}
catch (\Exception $e) {
$this->io->write(' <error>Could not apply patch! Skipping. The error was: ' . $e->getMessage() . '</error>');
if (getenv('COMPOSER_EXIT_ON_PATCH_FAILURE') || !empty($extra['composer-exit-on-patch-failure'])) {
if ($exitOnFailure) {
throw new \Exception("Cannot apply patch $description ($url)!");
}
}
Expand Down

0 comments on commit d011661

Please sign in to comment.