Skip to content

Commit 5f42395

Browse files
Merge pull request #87 from TheDragonCode/3.x
Resolved output buffer with call nested commands
2 parents 70bd32d + 09333f9 commit 5f42395

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

src/Concerns/Artisan.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace DragonCode\LaravelActions\Concerns;
66

77
use Illuminate\Support\Facades\Artisan as Command;
8+
use Symfony\Component\Console\Output\OutputInterface;
89

910
trait Artisan
1011
{
@@ -13,11 +14,12 @@ trait Artisan
1314
*
1415
* @param string $command
1516
* @param array $parameters
17+
* @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer
1618
*
1719
* @return void
1820
*/
19-
protected function artisan(string $command, array $parameters = []): void
21+
protected function artisan(string $command, array $parameters = [], ?OutputInterface $outputBuffer = null): void
2022
{
21-
Command::call($command, $parameters);
23+
Command::call($command, $parameters, $outputBuffer);
2224
}
2325
}

src/Contracts/Notification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace DragonCode\LaravelActions\Contracts;
66

77
use Closure;
8-
use Illuminate\Console\OutputStyle;
8+
use Symfony\Component\Console\Output\OutputInterface;
99

1010
interface Notification
1111
{
1212
public function info(string $string): void;
1313

1414
public function line(string $string, ?string $style = null): void;
1515

16-
public function setOutput(OutputStyle $output): self;
16+
public function setOutput(OutputInterface $output): self;
1717

1818
public function task(string $description, Closure $task): void;
1919

src/Notifications/Notification.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
use Closure;
88
use DragonCode\LaravelActions\Contracts\Notification as NotificationContract;
9-
use Illuminate\Console\OutputStyle;
109
use Symfony\Component\Console\Output\OutputInterface;
1110

1211
abstract class Notification implements NotificationContract
1312
{
14-
protected ?OutputStyle $output = null;
13+
protected ?OutputInterface $output = null;
1514

1615
protected int $verbosity = OutputInterface::VERBOSITY_NORMAL;
1716

@@ -25,7 +24,7 @@ abstract public function task(string $description, Closure $task): void;
2524

2625
abstract public function twoColumn(string $first, string $second): void;
2726

28-
public function setOutput(OutputStyle $output): NotificationContract
27+
public function setOutput(OutputInterface $output): NotificationContract
2928
{
3029
$this->output = $output;
3130

src/Processors/Migrate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function handle(): void
2323

2424
protected function ensureRepository(): void
2525
{
26-
$this->artisan(Names::INSTALL, [
26+
$this->runCommand(Names::INSTALL, [
2727
'--' . Options::CONNECTION => $this->options->connection,
2828
'--' . Options::FORCE => true,
2929
]);

src/Processors/Processor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use DragonCode\Support\Facades\Helpers\Arr;
1717
use DragonCode\Support\Facades\Helpers\Str;
1818
use DragonCode\Support\Filesystem\File;
19-
use Illuminate\Console\OutputStyle;
2019
use Illuminate\Contracts\Events\Dispatcher;
2120
use Symfony\Component\Console\Input\InputInterface;
21+
use Symfony\Component\Console\Output\OutputInterface;
2222

2323
abstract class Processor
2424
{
@@ -29,7 +29,7 @@ abstract public function handle(): void;
2929
public function __construct(
3030
protected Options $options,
3131
protected InputInterface $input,
32-
protected OutputStyle $output,
32+
protected OutputInterface $output,
3333
protected Config $config,
3434
protected ActionRepository $repository,
3535
protected Git $git,
@@ -57,7 +57,7 @@ protected function getFiles(string $path, ?Closure $filter = null): array
5757

5858
protected function runCommand(string $command, array $options = []): void
5959
{
60-
$this->artisan($command, array_filter($options));
60+
$this->artisan($command, array_filter($options), $this->output);
6161
}
6262

6363
protected function tableNotFound(): bool

src/Processors/Upgrade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected function replaceProperties(string $content): string
122122
protected function moveConfig(): void
123123
{
124124
$this->notification->task('Moving config file', function () {
125-
$this->artisan('vendor:publish', [
125+
$this->runCommand('vendor:publish', [
126126
'--provider' => ServiceProvider::class,
127127
'--force' => true,
128128
]);
@@ -144,7 +144,7 @@ protected function callMigration(): void
144144
? __DIR__ . '/../../database/migrations/anonymous/2022_08_18_180137_change_migration_actions_table.php'
145145
: __DIR__ . '/../../database/migrations/named/2022_08_18_180137_change_migration_actions_table.php';
146146

147-
$this->artisan('migrate', [
147+
$this->runCommand('migrate', [
148148
'--path' => $path,
149149
'--realpath' => true,
150150
'--force' => true,

src/Services/Migrator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use DragonCode\Support\Exceptions\FileNotFoundException;
1313
use DragonCode\Support\Facades\Helpers\Str;
1414
use DragonCode\Support\Filesystem\File;
15-
use Illuminate\Console\OutputStyle;
1615
use Illuminate\Contracts\Foundation\Application;
1716
use Illuminate\Support\Facades\DB;
17+
use Symfony\Component\Console\Output\OutputInterface;
1818
use Throwable;
1919

2020
class Migrator
@@ -35,7 +35,7 @@ public function setConnection(?string $connection): self
3535
return $this;
3636
}
3737

38-
public function setOutput(OutputStyle $output): self
38+
public function setOutput(OutputInterface $output): self
3939
{
4040
$this->notification->setOutput($output);
4141

0 commit comments

Comments
 (0)