Skip to content

Commit f5ad41f

Browse files
Skip all hooks in CI environments
1 parent 4082d26 commit f5ad41f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Console/Command/Hook.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function configure(): void
6969
protected function execute(InputInterface $input, OutputInterface $output): int
7070
{
7171
if ($this->shouldHooksBeSkipped()) {
72-
$output->writeLn('all hooks were skipped because of the environment variable CAPTAINHOOK_SKIP_HOOKS');
72+
$output->writeLn('all hooks were skipped because of the environment variable CAPTAINHOOK_SKIP_HOOKS or CI');
7373
return 0;
7474
}
7575

@@ -134,9 +134,21 @@ private function handleError(OutputInterface $output, Exception $e): int
134134
return 1;
135135
}
136136

137+
/**
138+
* Indicates if hooks should be skipped
139+
*
140+
* Either because of CI environment or the SKIP environment variable is set.
141+
*
142+
* @return bool
143+
*/
137144
private function shouldHooksBeSkipped(): bool
138145
{
139-
$skip = $_SERVER['CAPTAINHOOK_SKIP_HOOKS'] ?? 0;
140-
return (int) $skip === 1;
146+
foreach (['CAPTAINHOOK_SKIP_HOOKS', 'CI'] as $envVar) {
147+
$skip = (int) ($_SERVER[$envVar] ?? 0);
148+
if ($skip === 1) {
149+
return true;
150+
}
151+
}
152+
return false;
141153
}
142154
}

0 commit comments

Comments
 (0)