Skip to content

Commit

Permalink
Only output ending \n on shell if the shell command did anything
Browse files Browse the repository at this point in the history
Kinda janky coding :/ Not super proud of it.

Closes #104
  • Loading branch information
mattstauffer committed Sep 9, 2020
1 parent 0204d16 commit 79a4465
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Shell/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ public function __construct(ConsoleOutput $output)

public function exec(string $command, array $parameters = [], bool $quiet = false): Process
{
$didAnything = false;

$process = $this->buildProcess($command);
$process->run(function ($type, $buffer) use ($quiet) {
$process->run(function ($type, $buffer) use ($quiet, $didAnything) {
if (empty($buffer) || $buffer === PHP_EOL || $quiet) {
return;
}

$this->output->writeLn($this->formatMessage($buffer, $type === process::ERR));
$didAnything = true;
}, $parameters);

$this->output->writeLn("\n");
if ($didAnything) {
$this->output->writeLn("\n");
}

return $process;
}
Expand Down

0 comments on commit 79a4465

Please sign in to comment.