Skip to content

Commit caa2491

Browse files
committed
Disable incompatible pw-module installer during package update with event listener in plugin
1 parent 80d6c43 commit caa2491

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.1.1] - 2022-06-02
11+
12+
### Fixed
13+
- Improved compatibility when both wireframe-framework/processwire-composer-installer and hari/pw-module are enabled.
14+
1015
## [1.1.0] - 2020-12-09
1116

1217
### Added

src/ComposerInstaller/Plugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace wireframe\ComposerInstaller;
44

55
use Composer\Composer;
6+
use Composer\DependencyResolver\Operation\UpdateOperation;
67
use Composer\EventDispatcher\EventSubscriberInterface;
78
use Composer\IO\IOInterface;
89
use Composer\Plugin\PluginInterface;
@@ -43,6 +44,9 @@ public static function getSubscribedEvents()
4344
PackageEvents::PRE_PACKAGE_INSTALL => [
4445
array('prePackageInstall', 0)
4546
],
47+
PackageEvents::PRE_PACKAGE_UPDATE => [
48+
array('prePackageInstall', 0)
49+
],
4650
];
4751
}
4852

@@ -57,7 +61,8 @@ public static function getSubscribedEvents()
5761
*/
5862
public static function prePackageInstall(PackageEvent $event)
5963
{
60-
$package = $event->getOperation()->getPackage();
64+
$operation = $event->getOperation();
65+
$package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
6166
if ($package->getType() !== 'pw-module') return;
6267
$installationManager = $event->getComposer()->getInstallationManager();
6368
$moduleInstaller = $installationManager->getInstaller('pw-module');

0 commit comments

Comments
 (0)