Skip to content

Commit

Permalink
Merge pull request #167 from tighten/drift/suppress-tlint-output
Browse files Browse the repository at this point in the history
Suppress TLint output on success
  • Loading branch information
driftingly authored Dec 6, 2024
2 parents 74b38f7 + f9159d9 commit fc560b2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions app/Support/TLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
use Tighten\TLint\Commands\BaseCommand;
Expand Down Expand Up @@ -58,10 +59,17 @@ private function executeCommand(BaseCommand $tlintCommand): bool
$application->add($tlintCommand);
$application->setAutoExit(false);

return collect($this->dusterConfig->get('paths'))
$errors = collect($this->dusterConfig->get('paths'))
->map(fn ($path) => $this->executeCommandOnPath($path, $application))
->filter()
->isEmpty();
->filter();

if ($errors->isEmpty()) {
$this->success('No issues found.');

return true;
}

return false;
}

/**
Expand All @@ -75,9 +83,17 @@ private function executeCommandOnPath(string $path, Application $application): i

$command = $application->has('lint') ? 'lint' : 'format';

return $application->run(
$output = new BufferedOutput;

$exitCode = $application->run(
new StringInput("{$command} {$path}"),
app()->get(OutputInterface::class)
$output
);

if ($exitCode !== 0) {
app()->make(OutputInterface::class)->write($output->fetch());
}

return $exitCode;
}
}

0 comments on commit fc560b2

Please sign in to comment.