Skip to content

Commit

Permalink
style: apply fixes from qa
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Dec 16, 2024
1 parent 93379bb commit 7f09df9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Tempest/Console/src/Components/Interactive/TaskComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Tempest\Console\Components\ComponentState;
use Tempest\Console\Components\Concerns\HasErrors;
use Tempest\Console\Components\Concerns\HasState;
use Tempest\Console\Components\Renderers\KeyValueRenderer;
use Tempest\Console\Components\Renderers\SpinnerRenderer;
use Tempest\Console\Components\Renderers\TaskRenderer;
use Tempest\Console\InteractiveConsoleComponent;
Expand All @@ -24,8 +23,6 @@ final class TaskComponent implements InteractiveConsoleComponent
use HasErrors;
use HasState;

private KeyValueRenderer $keyValue;

private TaskRenderer $renderer;

private int $processId;
Expand All @@ -41,13 +38,10 @@ final class TaskComponent implements InteractiveConsoleComponent
private(set) array $extensions = ['pcntl'];

public function __construct(
private readonly string $label,
readonly string $label,
private null|Process|Closure $handler = null,
private readonly ?string $success = null,
private readonly ?string $failure = null,
) {
$this->handler = $this->resolveHandler($handler);
$this->keyValue = new KeyValueRenderer();
$this->renderer = new TaskRenderer(new SpinnerRenderer(), $label);
$this->startedAt = hrtime(as_number: true);
}
Expand Down Expand Up @@ -145,15 +139,15 @@ private function executeHandler(): void
$log = function (string ...$lines): void {
arr($lines)
->flatMap(fn (string $line) => explode("\n", $line))
->each(fn (string $line) => fwrite($this->sockets[0], $line));
->each(function (string $line): void {
fwrite($this->sockets[0], $line);
});
};

try {
exit((int) (($this->handler ?? static fn (): bool => true)($log) === false));
} catch (Throwable) {
exit(1);
} finally {
socket_close($conn);
}
}

Expand Down

0 comments on commit 7f09df9

Please sign in to comment.