Skip to content

Commit b4ce3e0

Browse files
Use the Util:getEnv method to read env vars
Fix issue #279
1 parent 2488218 commit b4ce3e0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Console/Command/Hook.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
namespace CaptainHook\App\Console\Command;
1313

1414
use CaptainHook\App\Config;
15-
use CaptainHook\App\Hook\Util;
15+
use CaptainHook\App\Hook\Util as HookUtil;
1616
use CaptainHook\App\Runner\Bootstrap\Util as BootstrapUtil;
17+
use CaptainHook\App\Runner\Util as RunnerUtil;
1718
use RuntimeException;
1819
use Symfony\Component\Console\Input\InputInterface;
1920
use Symfony\Component\Console\Input\InputOption;
@@ -97,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9798
try {
9899
$this->handleBootstrap($config);
99100

100-
$class = '\\CaptainHook\\App\\Runner\\Hook\\' . Util::getHookCommand($this->hookName);
101+
$class = '\\CaptainHook\\App\\Runner\\Hook\\' . HookUtil::getHookCommand($this->hookName);
101102
/** @var \CaptainHook\App\Runner\Hook $hook */
102103
$hook = new $class($io, $config, $repository);
103104
$hook->setPluginsDisabled($input->getOption('no-plugins'));
@@ -148,7 +149,7 @@ private function handleBootstrap(Config $config): void
148149
private function shouldHooksBeSkipped(): bool
149150
{
150151
foreach (['CAPTAINHOOK_SKIP_HOOKS', 'CI'] as $envVar) {
151-
$skip = (int) ($_SERVER[$envVar] ?? 0);
152+
$skip = (int) RunnerUtil::getEnv($envVar, "0");
152153
if ($skip === 1) {
153154
return true;
154155
}

src/Runner/Action/Cli/Command/Placeholder/Env.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace CaptainHook\App\Runner\Action\Cli\Command\Placeholder;
1313

14+
use CaptainHook\App\Runner\Util;
15+
1416
/**
1517
* Class Env
1618
*
@@ -36,6 +38,6 @@ public function replacement(array $options): string
3638
$var = $options['value-of'];
3739
$default = $options['default'] ?? '';
3840

39-
return (string) ($_ENV[$var] ?? $default);
41+
return Util::getEnv($var, $default);
4042
}
4143
}

0 commit comments

Comments
 (0)