Skip to content

Commit

Permalink
Added checkout command for docs #8
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna authored Nov 8, 2023
2 parents 57336b3 + f8c1389 commit f2fe54e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions routes/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Process;
use App\Docs;

/*
|--------------------------------------------------------------------------
Expand All @@ -17,3 +20,20 @@
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');


Artisan::command('checkout-latest-docs', function () {
// Update existing clones
collect(Docs::SUPPORT_VERSION)
->filter(fn(string $version) => Storage::disk('docs')->exists($version))
->every(fn(string $version) => Process::path(storage_path('docs/' . $version))->run('git pull'));


// Clone a new version if not already present
collect(Docs::SUPPORT_VERSION)
->filter(fn(string $version) => !Storage::disk('docs')->exists($version))
->every(fn(string $version) => Process::path(storage_path('docs'))
->run("git clone --single-branch --branch '$version' https://github.com/laravelRus/docs '$version'"));

})->purpose('Checkout the latest Laravel docs');

0 comments on commit f2fe54e

Please sign in to comment.