Skip to content

Commit

Permalink
Add no-files-exit-code option
Browse files Browse the repository at this point in the history
Add no-files-exit-code option
  • Loading branch information
vkryklyvenko authored Jun 8, 2022
1 parent b395e50 commit 3798119
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ protected function configure(): void
'q',
InputOption::VALUE_NONE,
'Allow to silently fail.'
)
->addOption(
'no-files-exit-code',
'nf',
InputOption::VALUE_NONE,
'Throw error if no files processed.'
);
}

Expand Down Expand Up @@ -153,19 +159,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$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 3798119

Please sign in to comment.