From 2f86a503f1f7838f5f7f399a17edd4d16eb95034 Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Sat, 14 Nov 2020 12:28:03 -0800 Subject: [PATCH] Composer 2 support (#36) Co-authored-by: hw Co-authored-by: VladimirAus --- composer.json | 6 +++--- src/Plugin.php | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index ea4b2da..11848ba 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "nested package" ], "homepage": "https://github.com/drupal-composer/preserve-paths", - "license": "GPL-2.0+", + "license": "GPL-2.0-or-later", "authors": [ { "name": "Johannes Haseitl", @@ -21,10 +21,10 @@ "issues": "https://github.com/drupal-composer/preserve-paths/issues" }, "require": { - "composer-plugin-api": "^1.0" + "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { - "composer/composer": "1.*", + "composer/composer": "^2.0", "phpunit/phpunit": "4.*", "derhasi/tempdirectory": "0.1.*", "squizlabs/php_codesniffer": "2.*", diff --git a/src/Plugin.php b/src/Plugin.php index f65468b..59ed1a6 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -12,7 +12,7 @@ use Composer\IO\IOInterface; use Composer\Plugin\PluginInterface; use Composer\Installer\PackageEvent; -use Composer\Script\ScriptEvents; +use Composer\Installer\PackageEvents; /** * Class Plugin. @@ -39,12 +39,12 @@ public function activate(Composer $composer, IOInterface $io) public static function getSubscribedEvents() { return array( - ScriptEvents::PRE_PACKAGE_INSTALL => 'prePackage', - ScriptEvents::POST_PACKAGE_INSTALL => 'postPackage', - ScriptEvents::PRE_PACKAGE_UPDATE => 'prePackage', - ScriptEvents::POST_PACKAGE_UPDATE => 'postPackage', - ScriptEvents::PRE_PACKAGE_UNINSTALL => 'prePackage', - ScriptEvents::POST_PACKAGE_UNINSTALL => 'postPackage', + PackageEvents::PRE_PACKAGE_INSTALL => 'prePackage', + PackageEvents::POST_PACKAGE_INSTALL => 'postPackage', + PackageEvents::PRE_PACKAGE_UPDATE => 'prePackage', + PackageEvents::POST_PACKAGE_UPDATE => 'postPackage', + PackageEvents::PRE_PACKAGE_UNINSTALL => 'prePackage', + PackageEvents::POST_PACKAGE_UNINSTALL => 'postPackage', ); } @@ -55,7 +55,6 @@ public static function getSubscribedEvents() */ public function prePackage(PackageEvent $event) { - $this->wrapper->prePackage($event); } @@ -68,4 +67,18 @@ public function postPackage(PackageEvent $event) { $this->wrapper->postPackage($event); } + + /** + * {@inheritdoc} + */ + public function deactivate(Composer $composer, IOInterface $io) + { + } + + /** + * {@inheritdoc} + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } }