Skip to content

Commit caf8bb5

Browse files
Delete Installer class
Use the existing CaptainHook\App\Composer\Cmd::setup instead.
1 parent 48e9125 commit caf8bb5

File tree

2 files changed

+17
-131
lines changed

2 files changed

+17
-131
lines changed

src/ComposerPlugin.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CaptainHook\Plugin\Composer;
1313

14+
use CaptainHook\App\Composer\Cmd;
1415
use Composer\Composer;
1516
use Composer\EventDispatcher\EventSubscriberInterface;
1617
use Composer\IO\IOInterface;
@@ -23,25 +24,20 @@
2324
*
2425
* @package CaptainHook\Plugin
2526
* @author Andrea Heigl <[email protected]>
26-
* @link https://github.com/captainhookphp/captainhook
27+
* @link https://github.com/captainhookphp/plugin-composer
2728
*/
2829
class ComposerPlugin implements PluginInterface, EventSubscriberInterface
2930
{
3031
/**
31-
* @var Installer
32-
*/
33-
private $installer;
34-
35-
/**
36-
* Activate the plugin by setting up the installer
32+
* Activate the plugin
3733
*
3834
* @param \Composer\Composer $composer
3935
* @param \Composer\IO\IOInterface $io
4036
* @return void
4137
*/
4238
public function activate(Composer $composer, IOInterface $io) : void
4339
{
44-
$this->installer = new Installer($io, $composer->getPackage());
40+
// nothing to do here
4541
}
4642

4743
/**
@@ -61,6 +57,7 @@ public static function getSubscribedEvents() : array
6157
*
6258
* @param \Composer\Script\Event $event
6359
* @return void
60+
* @throws \Exception
6461
*/
6562
public function installHooks(Event $event) : void
6663
{
@@ -71,13 +68,21 @@ public function installHooks(Event $event) : void
7168
require $vendorDir . '/autoload.php';
7269
}
7370

74-
// if it's still not available end the plugin execution
7571
if (!$this->isCaptainHookInstalled()) {
76-
$event->getIO()->write(' <info>CaptainHook not properly installed try to run composer update</info>');
72+
// if CaptainHook is still not available end the plugin execution
73+
// normally this only happens if CaptainHook gets uninstalled
74+
$event->getIO()->write(
75+
' <info>CaptainHook not properly installed try to run composer update</info>' . PHP_EOL .
76+
PHP_EOL .
77+
'If you are uninstalling CaptainHook, we are sad seeing you go, ' .
78+
'but we would appreciate your feedback on your experience.' . PHP_EOL .
79+
'Just go to https://github.com/CaptainHookPhp/captainhook/issues to leave your feedback' . PHP_EOL .
80+
PHP_EOL .
81+
'<comment>WARNING: Don\'t forget to deactivate the hooks in your .git/hooks directory.</comment>'
82+
);
7783
return;
7884
}
79-
// otherwise run the installer
80-
($this->installer)();
85+
Cmd::setup($event);
8186
}
8287

8388
/**

src/Installer.php

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)