|
5 | 5 | */ |
6 | 6 | namespace Vaimo\ComposerPatches\Compatibility; |
7 | 7 |
|
| 8 | +use Vaimo\ComposerPatches\Exceptions\OperationFailure; |
8 | 9 | use Vaimo\ComposerPatches\Patch\Definition as PatchDefinition; |
9 | 10 | use Composer\Repository\WritableRepositoryInterface; |
10 | 11 | use Composer\DependencyResolver\Operation\InstallOperation; |
@@ -82,15 +83,28 @@ public function processReinstallOperation( |
82 | 83 | return $installationManager->install($repository, $installOperation); |
83 | 84 | } |
84 | 85 |
|
85 | | - return $installationManager |
86 | | - ->uninstall($repository, $uninstallOperation) |
87 | | - ->then(function () use ($installationManager, $installOperation, $repository) { |
88 | | - $package = $installOperation->getPackage(); |
89 | | - $installationManager->getInstaller($package->getType()) |
90 | | - ->download($package) |
91 | | - ->then(function () use ($installationManager, $installOperation, $repository) { |
92 | | - $installationManager->install($repository, $installOperation); |
93 | | - }); |
94 | | - }); |
| 86 | + $package = $installOperation->getPackage(); |
| 87 | + $installer = $installationManager->getInstaller($package->getType()); |
| 88 | + |
| 89 | + $uninstallPromise = $installationManager->uninstall($repository, $uninstallOperation); |
| 90 | + if (!$uninstallPromise) { |
| 91 | + throw new OperationFailure(sprintf('Uninstallation of %s failed', $package->getName())); |
| 92 | + } |
| 93 | + |
| 94 | + $downloadPromise = $installer->download($package); |
| 95 | + if (!$downloadPromise) { |
| 96 | + throw new OperationFailure(sprintf('Download of %s failed', $package->getName())); |
| 97 | + } |
| 98 | + |
| 99 | + $promise = \React\Promise\all([$uninstallPromise, $downloadPromise]); |
| 100 | + |
| 101 | + return $promise->then(static function () use ($installationManager, $installOperation, $repository, $package) { |
| 102 | + $installPromise = $installationManager->install($repository, $installOperation); |
| 103 | + if (!$installPromise) { |
| 104 | + throw new OperationFailure(sprintf('Install of %s failed', $package->getName())); |
| 105 | + } |
| 106 | + |
| 107 | + return $installPromise->then(static function () {}); |
| 108 | + }); |
95 | 109 | } |
96 | 110 | } |
0 commit comments