Files
newznab-tmux/app/Console/Commands/UpdateNNTmuxGit.php
T
2023-03-02 16:47:20 +01:00

51 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Blacklight\Tmux;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process;
class UpdateNNTmuxGit extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'nntmux:git';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update NNTmux from git repository';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
public function handle(): void
{
$wasRunning = false;
if ((new Tmux())->isRunning() === true) {
$wasRunning = true;
$this->call('tmux-ui:stop', ['--kill' => true]);
}
$this->output->writeln('<comment>Getting changes from Github</comment>');
$process = Process::run('git pull');
echo $process->output();
echo $process->errorOutput();
if ($wasRunning === true) {
$this->call('tmux-ui:start');
}
}
}