Forráskód Böngészése

Exit with non-success code if there are warnings

shalvah 2 éve
szülő
commit
67b77cb30b
2 módosított fájl, 13 hozzáadás és 7 törlés
  1. 3 0
      phpunit.xml
  2. 10 7
      src/Commands/GenerateDocumentation.php

+ 3 - 0
phpunit.xml

@@ -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>

+ 10 - 7
src/Commands/GenerateDocumentation.php

@@ -66,14 +66,9 @@ class GenerateDocumentation extends Command
         $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 @@ class GenerateDocumentation extends Command
 
     }
 
-    protected function sayGoodbye(): void
+    protected function sayGoodbye(bool $errored = false): void
     {
         $message = 'All done. ';
         if ($this->docConfig->get('type') == 'laravel') {
@@ -200,5 +195,13 @@ class GenerateDocumentation extends Command
 
         $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);
+            }
+        }
     }
 }