diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 9dccfced3..44ccfa60b 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -40,7 +40,7 @@ class DiagnoseCommand extends BaseCommand protected $process; /** @var int */ - protected $failures = 0; + protected $exitCode = 0; protected function configure() { @@ -50,6 +50,8 @@ class DiagnoseCommand extends BaseCommand ->setHelp(<<diagnose command checks common errors to help debugging problems. +The process exit code will be 1 in case of warnings and 2 for errors. + EOT ) ; @@ -147,7 +149,7 @@ EOT $this->outputResult($this->checkVersion($config)); } - return $this->failures; + return $this->exitCode; } private function checkComposerSchema() @@ -385,12 +387,12 @@ EOT private function outputResult($result) { $io = $this->getIO(); - $hadError = false; if (true === $result) { $io->write('OK'); return; } + $hadError = false; if ($result instanceof \Exception) { $result = '['.get_class($result).'] '.$result->getMessage().''; } @@ -411,9 +413,10 @@ EOT if ($hadError) { $io->write('FAIL'); - $this->failures++; + $this->exitCode = 2; } else { $io->write('WARNING'); + $this->exitCode = 1; } if ($result) {