From 3477b739cde897e19544586241e4eeb3e34be975 Mon Sep 17 00:00:00 2001 From: Sebastian Feldmann Date: Tue, 27 Jul 2021 13:30:49 +0200 Subject: [PATCH] Move disabled checks In order to really disable the plugin at the right point the checks had to be moved. This should fix issue #3 --- src/Plugin.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 421e1ed..2e6f7ea 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -83,6 +83,14 @@ public static function getSubscribedEvents() */ public function installOrUpdateFunction(PackageEvent $event): void { + if ($this->isPluginDisabled()) { + $this->getIO()->write(' plugin is disabled'); + return; + } + if (getenv('CI') === 'true') { + $this->getIO()->write(' disabling plugin due to CI-environment'); + return; + } // download phar and check signature parent::installOrUpdateFunction($event); // try to configure and install hooks @@ -100,16 +108,6 @@ public function configureHooks(): void $this->isPackageUpdate = true; $this->getIO()->write('CaptainHook'); - if ($this->isPluginDisabled()) { - $this->getIO()->write(' plugin is disabled'); - return; - } - - if (getenv('CI') === 'true') { - $this->getIO()->write(' disabling plugin due to CI-environment'); - return; - } - $this->detectConfiguration(); $this->detectGitDir(); $this->detectCaptainExecutable(); @@ -218,11 +216,11 @@ private function detectCaptainExecutable(): void { $extra = $this->getComposer()->getPackage()->getExtra(); if (isset($extra['captainhook']['exec'])) { - $this->executable = $extra['captainhook']['exec']; + $this->executable = (string) $extra['captainhook']['exec']; return; } - $this->executable = (string) $this->getComposer()->getConfig()->get('bin-dir') . '/captainhook'; + $this->executable = $this->getComposer()->getConfig()->get('bin-dir') . '/captainhook'; } /**