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 99use Composer \Package \PackageInterface ;
1010use Composer \Repository \InstalledRepositoryInterface ;
1111use Composer \Util \Filesystem ;
12+ use React \Promise \PromiseInterface ;
1213
1314class Installer extends LibraryInstaller
1415{
@@ -160,9 +161,21 @@ public function getInstallPath(PackageInterface $package)
160161
161162 public function uninstall (InstalledRepositoryInterface $ repo , PackageInterface $ package )
162163 {
163- parent ::uninstall ($ repo , $ package );
164164 $ 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 ();
166179 }
167180
168181 /**
You can’t perform that action at this time.
0 commit comments