Upgrade to rc5
This commit is contained in:
@@ -2,24 +2,25 @@
|
||||
|
||||
namespace Kirby\ComposerInstaller;
|
||||
|
||||
use RuntimeException;
|
||||
use Composer\Installer\LibraryInstaller;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use React\Promise\PromiseInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @package Kirby Composer Installer
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
* @link https://getkirby.com
|
||||
* @copyright Bastian Allgeier
|
||||
* @license MIT
|
||||
* @copyright Bastian Allgeier GmbH
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
*/
|
||||
class Installer extends LibraryInstaller
|
||||
{
|
||||
/**
|
||||
* Decides if the installer supports the given type
|
||||
*
|
||||
* @param string $packageType
|
||||
* @param string $packageType
|
||||
* @return bool
|
||||
*/
|
||||
public function supports($packageType): bool
|
||||
@@ -30,34 +31,54 @@ class Installer extends LibraryInstaller
|
||||
/**
|
||||
* Installs specific package.
|
||||
*
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $package package instance
|
||||
*/
|
||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
// first install the package normally...
|
||||
parent::install($repo, $package);
|
||||
$promise = parent::install($repo, $package);
|
||||
|
||||
// ...then run custom code
|
||||
$this->postInstall($package);
|
||||
$postInstall = function () use ($package) {
|
||||
$this->postInstall($package);
|
||||
};
|
||||
|
||||
// Composer 2 in async mode
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise->then($postInstall);
|
||||
}
|
||||
|
||||
// Composer 1 or Composer 2 without async
|
||||
$postInstall();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates specific package.
|
||||
*
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $initial already installed package version
|
||||
* @param PackageInterface $target updated version
|
||||
* @param InstalledRepositoryInterface $repo repository in which to check
|
||||
* @param PackageInterface $initial already installed package version
|
||||
* @param PackageInterface $target updated version
|
||||
*
|
||||
* @throws InvalidArgumentException if $initial package is not installed
|
||||
*/
|
||||
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
||||
{
|
||||
// first update the package normally...
|
||||
parent::update($repo, $initial, $target);
|
||||
$promise = parent::update($repo, $initial, $target);
|
||||
|
||||
// ...then run custom code
|
||||
$this->postInstall($target);
|
||||
$postInstall = function () use ($target) {
|
||||
$this->postInstall($target);
|
||||
};
|
||||
|
||||
// Composer 2 in async mode
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise->then($postInstall);
|
||||
}
|
||||
|
||||
// Composer 1 or Composer 2 without async
|
||||
$postInstall();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user