Files
core/bin/composer-script/run.php
2020-11-08 16:54:15 +01:00

19 lines
587 B
PHP

<?php
use Symfony\Component\Console\Style\SymfonyStyle;
function run(string $command, SymfonyStyle $symfonyStyle, bool $withOutput = false): void {
exec($command, $output, $return);
if ($return) {
// Some error occurred.
$message = sprintf("Command '%s' failed. %s", $command, implode("\n", $output));
$symfonyStyle->error($message);
} else {
if ($withOutput) {
$symfonyStyle->text($output);
}
$message = sprintf("Command '%s' executed successfully.", $command);
$symfonyStyle->success($message);
}
}