diff --git a/phpunit.xml b/phpunit.xml index ca7993a0..aed42cdd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,6 +20,9 @@ src/ScribeServiceProvider.php + + + tests/GenerateDocumentation/OutputTest.php diff --git a/src/Commands/GenerateDocumentation.php b/src/Commands/GenerateDocumentation.php index 79f9b260..a7c8ef7a 100644 --- a/src/Commands/GenerateDocumentation.php +++ b/src/Commands/GenerateDocumentation.php @@ -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 @@ -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') { @@ -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); + } + } } }