Skip to content

Commit

Permalink
Exit with non-success code if there are warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Nov 18, 2022
1 parent 0b9473b commit 67b77cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<file>src/ScribeServiceProvider.php</file>
</exclude>
</coverage>
<php>
<server name="SCRIBE_TESTS" value="1" />
</php>
<testsuites>
<testsuite name="Full Test">
<file>tests/GenerateDocumentation/OutputTest.php</file>
Expand Down
17 changes: 10 additions & 7 deletions src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,9 @@ public function handle(RouteMatcherInterface $routeMatcher, GroupedEndpointsFact
$writer = new Writer($this->docConfig, $this->configName);
$writer->writeDocs($groupedEndpoints);

if ($groupedEndpointsInstance->hasEncounteredErrors()) {
c::warn('Generated docs, but encountered some errors while processing routes.');
c::warn('Check the output above for details.');
}

$this->upgradeConfigFileIfNeeded();

$this->sayGoodbye();
$this->sayGoodbye(errored: $groupedEndpointsInstance->hasEncounteredErrors());
}

public function isForcing(): bool
Expand Down Expand Up @@ -187,7 +182,7 @@ protected function upgradeConfigFileIfNeeded(): void

}

protected function sayGoodbye(): void
protected function sayGoodbye(bool $errored = false): void
{
$message = 'All done. ';
if ($this->docConfig->get('type') == 'laravel') {
Expand All @@ -200,5 +195,13 @@ protected function sayGoodbye(): void

$this->newLine();
c::success($message);

if ($errored) {
c::warn('Generated docs, but encountered some errors while processing routes.');
c::warn('Check the output above for details.');
if (empty($_SERVER["SCRIBE_TESTS"])) {
exit(2);
}
}
}
}

0 comments on commit 67b77cb

Please sign in to comment.