Skip to content

Commit

Permalink
Merge pull request #88 from AkrilliA/feature/laravel-v10
Browse files Browse the repository at this point in the history
Feature/laravel v10
  • Loading branch information
regnerisch authored Feb 22, 2023
2 parents ce70d86 + 3e18269 commit 92b2658
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php: ['8.0', '8.1', '8.2']
php: ['8.1', '8.2']

steps:
- name: Checkout
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"illuminate/support": "^9.0|^10.0",
"illuminate/console": "^9.0|^10.0",
"illuminate/filesystem": "^9.0|^10.0",
"regnerisch/laravel-command-hooks": "^2.0"
"illuminate/filesystem": "^9.0|^10.0"
},
"extra": {
"laravel": {
Expand Down
45 changes: 44 additions & 1 deletion src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
namespace AkrilliA\LaravelBeyond\Commands;

use AkrilliA\LaravelBeyond\Contracts\Composer as ComposerContract;
use Regnerisch\LaravelCommandHooks\Command;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Isolatable;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

abstract class BaseCommand extends Command
{
Expand Down Expand Up @@ -65,6 +68,46 @@ protected function checkVersionId(): int
return 0;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this instanceof Isolatable && $this->option('isolated') !== false &&
! $this->commandIsolationMutex()->create($this)) {
$this->comment(sprintf(
'The [%s] command is already running.', $this->getName()
));

return (int) (is_numeric($this->option('isolated'))
? $this->option('isolated')
: self::SUCCESS);
}

$code = null;

if (method_exists($this, 'before')) {
$code = $this->before();

if ($code) {
return (int) $code;
}
}

$method = method_exists($this, 'handle') ? 'handle' : '__invoke';

try {
$originalCode = (int) $this->laravel->call([$this, $method]);

if (method_exists($this, 'after')) {
$code = $this->after($originalCode);
}

return is_null($code) ? $originalCode : (int) $code;
} finally {
if ($this instanceof Isolatable && $this->option('isolated') !== false) {
$this->commandIsolationMutex()->forget($this);
}
}
}

protected function getMissingPackages(): array
{
$composer = $this->getLaravel()->get(ComposerContract::class);
Expand Down

0 comments on commit 92b2658

Please sign in to comment.