Skip to content

Commit

Permalink
Merge pull request #126 from vkryklyvenko/patch-1
Browse files Browse the repository at this point in the history
Add no-files-exit-code option
  • Loading branch information
overtrue authored Jun 2, 2022
2 parents b7ce82f + 995b29f commit 02cdc34
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
}

Expand Down Expand Up @@ -204,19 +210,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$fileCount = count($linter->getFiles());
$code = 0;

if ($fileCount <= 0) {
$output->writeln('<info>Could not find files to lint</info>');

return 0;

if (!empty($options['no-files-exit-code'])) {
$code = 1;
}

return $code;
}

$errors = $this->executeLint($linter, $input, $output, $fileCount);

$timeUsage = Helper::formatTime(microtime(true) - $startTime);
$memUsage = Helper::formatMemory(memory_get_usage(true) - $startMemUsage);

$code = 0;
$errCount = count($errors);

$output->writeln(sprintf(
Expand Down

0 comments on commit 02cdc34

Please sign in to comment.