5
5
*/
6
6
namespace Vaimo \ComposerPatches \Compatibility ;
7
7
8
+ use Composer \Composer ;
9
+ use Composer \Util \SyncHelper ;
10
+ use React \Promise \Promise ;
11
+ use Vaimo \ComposerPatches \Exceptions \OperationFailure ;
8
12
use Vaimo \ComposerPatches \Patch \Definition as PatchDefinition ;
9
13
use Composer \Repository \WritableRepositoryInterface ;
10
14
use Composer \DependencyResolver \Operation \InstallOperation ;
@@ -76,7 +80,8 @@ public function processReinstallOperation(
76
80
WritableRepositoryInterface $ repository ,
77
81
InstallationManager $ installationManager ,
78
82
InstallOperation $ installOperation ,
79
- UninstallOperation $ uninstallOperation
83
+ UninstallOperation $ uninstallOperation ,
84
+ Composer $ composer
80
85
) {
81
86
if (version_compare (\Composer \Composer::VERSION , '2.0 ' , '< ' )) {
82
87
return $ installationManager ->install ($ repository , $ installOperation );
@@ -85,12 +90,18 @@ public function processReinstallOperation(
85
90
$ package = $ installOperation ->getPackage ();
86
91
$ installer = $ installationManager ->getInstaller ($ package ->getType ());
87
92
88
- $ installationManager ->uninstall ($ repository , $ uninstallOperation );
93
+ $ promise = $ installationManager ->uninstall ($ repository , $ uninstallOperation );
94
+ if (!$ promise instanceof Promise) {
95
+ throw new OperationFailure ("Uninstallation of {$ package ->getName ()} failed " );
96
+ }
89
97
90
- return $ installer
91
- ->download ($ package )
92
- ->then (function () use ($ installationManager , $ installOperation , $ repository ) {
93
- $ installationManager ->install ($ repository , $ installOperation );
94
- });
98
+ return $ promise ->then (static function () use ($ composer , $ installer , $ package ) {
99
+ return SyncHelper::downloadAndInstallPackageSync (
100
+ $ composer ->getLoop (),
101
+ $ composer ->getDownloadManager (),
102
+ $ installer ->getInstallPath ($ package ),
103
+ $ package
104
+ );
105
+ });
95
106
}
96
107
}
0 commit comments