mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 17:35:36 +08:00
Add WindowsCMakeExecutor
This commit is contained in:
@@ -149,7 +149,8 @@ abstract class Shell
|
||||
?string $original_command = null,
|
||||
bool $capture_output = false,
|
||||
bool $throw_on_error = true,
|
||||
?string $cwd = null
|
||||
?string $cwd = null,
|
||||
?array $env = null,
|
||||
): array {
|
||||
$file_res = null;
|
||||
if ($this->enable_log_file) {
|
||||
@@ -164,7 +165,13 @@ abstract class Shell
|
||||
1 => PHP_OS_FAMILY === 'Windows' ? ['socket'] : ['pipe', 'w'], // stdout
|
||||
2 => PHP_OS_FAMILY === 'Windows' ? ['socket'] : ['pipe', 'w'], // stderr
|
||||
];
|
||||
$process = proc_open($cmd, $descriptors, $pipes, $cwd);
|
||||
if ($env !== null && $env !== []) {
|
||||
// merge current PHP envs
|
||||
$env = array_merge(getenv(), $env);
|
||||
} else {
|
||||
$env = null;
|
||||
}
|
||||
$process = proc_open($cmd, $descriptors, $pipes, $cwd, env_vars: $env);
|
||||
|
||||
$output_value = '';
|
||||
try {
|
||||
|
||||
@@ -45,23 +45,11 @@ class WindowsCmd extends Shell
|
||||
logger()->debug('Running command with result: ' . $cmd);
|
||||
}
|
||||
$cmd = $this->getExecString($cmd);
|
||||
$result = $this->passthru($cmd, $this->console_putput, $cmd, capture_output: true, throw_on_error: false, cwd: $this->cd);
|
||||
$result = $this->passthru($cmd, $this->console_putput, $cmd, capture_output: true, throw_on_error: false, cwd: $this->cd, env: $this->env);
|
||||
$out = explode("\n", $result['output']);
|
||||
return [$result['code'], $out];
|
||||
}
|
||||
|
||||
public function setEnv(array $env): static
|
||||
{
|
||||
// windows currently does not support setting environment variables
|
||||
throw new SPCInternalException('Windows does not support setting environment variables in shell commands.');
|
||||
}
|
||||
|
||||
public function appendEnv(array $env): static
|
||||
{
|
||||
// windows currently does not support appending environment variables
|
||||
throw new SPCInternalException('Windows does not support appending environment variables in shell commands.');
|
||||
}
|
||||
|
||||
public function getLastCommand(): string
|
||||
{
|
||||
return $this->last_cmd;
|
||||
|
||||
Reference in New Issue
Block a user