Final Class Yiisoft\Yii\Debug\Api\Inspector\Command\BashCommand
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $aliases | \ |
|
| $command | array | |
public function __construct(
private Aliases $aliases,
private array $command,
) {}
| public static string getDescription ( ) |
public static function getDescription(): string
{
return 'Runs any commands from the project root.';
}
| public Yiisoft\ |
public function run(): CommandResponse
{
$projectDirectory = $this->aliases->get('@root');
$process = new Process($this->command);
$process
->setWorkingDirectory($projectDirectory)
->setTimeout(null)
->run();
$processOutput = rtrim($process->getOutput());
if (!$process->getExitCode() > 1) {
return new CommandResponse(
status: CommandResponse::STATUS_FAIL,
result: null,
errors: array_filter([$processOutput, $process->getErrorOutput()]),
);
}
return new CommandResponse(
status: $process->isSuccessful() ? CommandResponse::STATUS_OK : CommandResponse::STATUS_ERROR,
result: $processOutput . $process->getErrorOutput(),
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.