diff --git a/src/Command/LintCommand.php b/src/Command/LintCommand.php index 61962252..77518240 100644 --- a/src/Command/LintCommand.php +++ b/src/Command/LintCommand.php @@ -139,6 +139,12 @@ protected function configure() 'q', InputOption::VALUE_NONE, 'Allow to silenty fail.' + ) + ->addOption( + 'no-files-exit-code', + 'nf', + InputOption::VALUE_NONE, + 'Throw error if no files processed.' ); } @@ -204,11 +210,16 @@ protected function execute(InputInterface $input, OutputInterface $output) } $fileCount = count($linter->getFiles()); + $code = 0; if ($fileCount <= 0) { $output->writeln('Could not find files to lint'); - - return 0; + + if (!empty($options['no-files-exit-code'])) { + $code = 1; + } + + return $code; } $errors = $this->executeLint($linter, $input, $output, $fileCount); @@ -216,7 +227,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $timeUsage = Helper::formatTime(microtime(true) - $startTime); $memUsage = Helper::formatMemory(memory_get_usage(true) - $startMemUsage); - $code = 0; $errCount = count($errors); $output->writeln(sprintf(