File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 9
9
use Composer \Package \PackageInterface ;
10
10
use Composer \Repository \InstalledRepositoryInterface ;
11
11
use Composer \Util \Filesystem ;
12
+ use React \Promise \PromiseInterface ;
12
13
13
14
class Installer extends LibraryInstaller
14
15
{
@@ -160,9 +161,21 @@ public function getInstallPath(PackageInterface $package)
160
161
161
162
public function uninstall (InstalledRepositoryInterface $ repo , PackageInterface $ package )
162
163
{
163
- parent ::uninstall ($ repo , $ package );
164
164
$ installPath = $ this ->getPackageBasePath ($ package );
165
- $ this ->io ->write (sprintf ('Deleting %s - %s ' , $ installPath , !file_exists ($ installPath ) ? '<comment>deleted</comment> ' : '<error>not deleted</error> ' ));
165
+ $ io = $ this ->io ;
166
+ $ outputStatus = function () use ($ io , $ installPath ) {
167
+ $ io ->write (sprintf ('Deleting %s - %s ' , $ installPath , !file_exists ($ installPath ) ? '<comment>deleted</comment> ' : '<error>not deleted</error> ' ));
168
+ };
169
+
170
+ $ promise = parent ::uninstall ($ repo , $ package );
171
+
172
+ // Composer v2 might return a promise here
173
+ if ($ promise instanceof PromiseInterface) {
174
+ return $ promise ->then ($ outputStatus );
175
+ }
176
+
177
+ // If not, execute the code right away as parent::uninstall executed synchronously (composer v1, or v2 without async)
178
+ $ outputStatus ();
166
179
}
167
180
168
181
/**
You can’t perform that action at this time.
0 commit comments