Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI-1130: Not all processes should use STDIN #1650

Merged
merged 2 commits into from
Dec 14, 2023
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
13 changes: 5 additions & 8 deletions src/Helpers/LocalMachineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
return (bool) $this->installedBinaries[$command];
}
$osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command];
$exists = $this->execute($osCommand, NULL, NULL, FALSE)->isSuccessful();
$exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, FALSE)->isSuccessful();

Check warning on line 59 in src/Helpers/LocalMachineHelper.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ return (bool) $this->installedBinaries[$command]; } $osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command]; - $exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, FALSE)->isSuccessful(); + $exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, true)->isSuccessful(); $this->installedBinaries[$command] = $exists; return $exists; }

Check warning on line 59 in src/Helpers/LocalMachineHelper.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ return (bool) $this->installedBinaries[$command]; } $osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command]; - $exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, FALSE)->isSuccessful(); + $exists = $this->execute($osCommand, NULL, NULL, true, NULL, NULL, FALSE)->isSuccessful(); $this->installedBinaries[$command] = $exists; return $exists; }
$this->installedBinaries[$command] = $exists;
return $exists;
}
Expand All @@ -71,13 +71,10 @@

/**
* Executes a buffered command.
*
* @param array $cmd The command to execute.
* @param null $callback A function to run while waiting for the process to complete.
*/
public function execute(array $cmd, callable $callback = NULL, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL): Process {
public function execute(array $cmd, callable $callback = NULL, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL, bool $stdin = TRUE): Process {
$process = new Process($cmd);
$process = $this->configureProcess($process, $cwd, $printOutput, $timeout, $env);
$process = $this->configureProcess($process, $cwd, $printOutput, $timeout, $env, $stdin);
return $this->executeProcess($process, $callback, $printOutput);
}

Expand Down Expand Up @@ -106,8 +103,8 @@
* @param string|null $cwd
* @param array|null $env
*/
private function configureProcess(Process $process, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL): Process {
if (function_exists('posix_isatty') && !@posix_isatty(STDIN)) {
private function configureProcess(Process $process, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL, bool $stdin = TRUE): Process {
if (function_exists('posix_isatty') && !@posix_isatty(STDIN) && $stdin) {
$process->setInput(STDIN);
}
if ($cwd) {
Expand Down