Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Turbo/TurboRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Nette\Utils\FileSystem;
use Nette\Utils\Json;
use Symplify\EasyCodingStandard\Exception\ShouldNotHappenException;

/**
* Experimental --turbo mode: hands the run over to the "ecs-go" Go binary instead
Expand Down Expand Up @@ -34,13 +35,16 @@ public function run(array $configData, bool $isFixMode): int
try {
$arguments = $this->createArguments($binary, $configPath, $isFixMode);

// symfony/process is in "replace"; passthru streams ecs-go's output straight through
// string command, as the array form needs PHP 7.4 and the release is downgraded to 7.2
$command = implode(' ', array_map(escapeshellarg(...), $arguments));

$exitCode = 0;
passthru($command, $exitCode);
// inherit the terminal, so ecs-go detects a TTY and colors its output
$process = proc_open($command, [STDIN, STDOUT, STDERR], $pipes);
if (! is_resource($process)) {
throw new ShouldNotHappenException(sprintf('Unable to start "%s"', $binary));
}

return $exitCode;
return proc_close($process);
} finally {
FileSystem::delete($configPath);
}
Expand Down
Loading