Skip to content

Commit f08f20b

Browse files
edgardmessiasDavertMik
authored andcommitted
Fixed error on composer update (Fix #30) (#31)
1 parent 8adf2a1 commit f08f20b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: Installer.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php
22
namespace Codeception\c3;
33
use Composer\Composer;
4+
use Composer\DependencyResolver\Operation\InstallOperation;
5+
use Composer\DependencyResolver\Operation\UninstallOperation;
6+
use Composer\DependencyResolver\Operation\UpdateOperation;
47
use Composer\EventDispatcher\EventSubscriberInterface;
8+
use Composer\Installer\PackageEvent;
59
use Composer\IO\IOInterface;
610
use Composer\Plugin\PluginInterface;
711
use Composer\Script\Event;
812
use Composer\Script\ScriptEvents;
9-
use Composer\Installer\PackageEvent;
1013

1114
class Installer implements PluginInterface, EventSubscriberInterface
1215
{
@@ -22,8 +25,16 @@ public function activate(Composer $composer, IOInterface $io)
2225

2326
protected function isOperationOnC3(PackageEvent $event)
2427
{
25-
list(, $name) = explode('/', $event->getOperation()->getPackage()->getName());
26-
28+
$name = '';
29+
30+
if ($event->getOperation() instanceof InstallOperation) {
31+
list(, $name) = explode('/', $event->getOperation()->getPackage()->getName());
32+
} elseif ($event->getOperation() instanceof UpdateOperation) {
33+
list(, $name) = explode('/', $event->getOperation()->getTargetPackage()->getName());
34+
} elseif ($event->getOperation() instanceof UninstallOperation) {
35+
list(, $name) = explode('/', $event->getOperation()->getPackage()->getName());
36+
}
37+
2738
return $name === 'c3';
2839
}
2940

0 commit comments

Comments
 (0)