Simplify promise handling
parent
a732ea5dd8
commit
5c62c7d566
|
@ -229,29 +229,15 @@ class InstallationManager
|
||||||
$loop = $this->loop;
|
$loop = $this->loop;
|
||||||
$io = $this->io;
|
$io = $this->io;
|
||||||
|
|
||||||
$promise = new \React\Promise\Promise(function ($resolve, $reject) use ($installer, $jobType, $package, $initialPackage) {
|
$promise = $installer->prepare($jobType, $package, $initialPackage);
|
||||||
$promise = $installer->prepare($jobType, $package, $initialPackage);
|
if (null === $promise) {
|
||||||
if (null === $promise) {
|
$promise = new \React\Promise\Promise(function ($resolve, $reject) { $resolve(); });
|
||||||
$promise = new \React\Promise\Promise(function ($resolve, $reject) { $resolve(); });
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $promise->then($resolve, $reject);
|
|
||||||
});
|
|
||||||
|
|
||||||
$promise = $promise->then(function () use ($jobType, $installManager, $repo, $operation) {
|
$promise = $promise->then(function () use ($jobType, $installManager, $repo, $operation) {
|
||||||
$promise = $installManager->$jobType($repo, $operation);
|
return $installManager->$jobType($repo, $operation);
|
||||||
if (null === $promise) {
|
|
||||||
$promise = new \React\Promise\Promise(function ($resolve, $reject) { $resolve(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
return $promise;
|
|
||||||
})->then(function () use ($jobType, $installer, $package, $initialPackage) {
|
})->then(function () use ($jobType, $installer, $package, $initialPackage) {
|
||||||
$promise = $installer->cleanup($jobType, $package, $initialPackage);
|
return $installer->cleanup($jobType, $package, $initialPackage);
|
||||||
if (null === $promise) {
|
|
||||||
$promise = new \React\Promise\Promise(function ($resolve, $reject) { $resolve(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
return $promise;
|
|
||||||
})->then(function () use ($jobType, $installer, $package, $initialPackage, $runScripts, $dispatcher, $installManager, $devMode, $repo, $operations, $operation) {
|
})->then(function () use ($jobType, $installer, $package, $initialPackage, $runScripts, $dispatcher, $installManager, $devMode, $repo, $operations, $operation) {
|
||||||
$repo->write($devMode, $installManager);
|
$repo->write($devMode, $installManager);
|
||||||
|
|
||||||
|
@ -263,7 +249,9 @@ class InstallationManager
|
||||||
$this->io->writeError(' <error>' . ucfirst($jobType) .' of '.$package->getPrettyName().' failed</error>');
|
$this->io->writeError(' <error>' . ucfirst($jobType) .' of '.$package->getPrettyName().' failed</error>');
|
||||||
|
|
||||||
$promise = $installer->cleanup($jobType, $package, $initialPackage);
|
$promise = $installer->cleanup($jobType, $package, $initialPackage);
|
||||||
$loop->wait(array($promise));
|
if ($promise) {
|
||||||
|
$loop->wait(array($promise));
|
||||||
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue