mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
31 lines
763 B
PHP
31 lines
763 B
PHP
<?php
|
|
|
|
namespace Cli\Services;
|
|
|
|
use Exception;
|
|
|
|
class ArtisanRunner
|
|
{
|
|
public function __construct(
|
|
protected string $appDir
|
|
) {
|
|
}
|
|
|
|
public function run(array $commandArgs)
|
|
{
|
|
$errors = (new ProgramRunner('php', '/usr/bin/php'))
|
|
->withTimeout(60)
|
|
->withIdleTimeout(5)
|
|
->withEnvironment(EnvironmentLoader::load($this->appDir))
|
|
->runCapturingAllOutput([
|
|
$this->appDir . DIRECTORY_SEPARATOR . 'artisan',
|
|
'-n', '-q',
|
|
...$commandArgs
|
|
]);
|
|
|
|
if ($errors) {
|
|
$cmdString = implode(' ', $commandArgs);
|
|
throw new Exception("Failed 'php artisan {$cmdString}' with errors:\n" . $errors);
|
|
}
|
|
}
|
|
} |