Skip to content

Commit e270a39

Browse files
committed
Guard migrator status output
1 parent 29b1e5c commit e270a39

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/Migrator.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use DirectoryTree\OpenSearchMigrations\Repositories\MigrationRepository;
99
use Illuminate\Console\OutputStyle;
1010
use Illuminate\Support\Collection;
11+
use Symfony\Component\Console\Output\NullOutput;
12+
use Symfony\Component\Console\Output\OutputInterface;
1113

1214
/**
1315
* Runs and rolls back OpenSearch migration files.
@@ -17,7 +19,7 @@ class Migrator
1719
/**
1820
* The console output implementation.
1921
*/
20-
protected OutputStyle $output;
22+
protected OutputInterface $output;
2123

2224
/**
2325
* Create a new migrator instance.
@@ -26,7 +28,9 @@ public function __construct(
2628
protected MigrationRepository $migrationRepository,
2729
protected MigrationStorage $migrationStorage,
2830
protected MigrationFactory $migrationFactory
29-
) {}
31+
) {
32+
$this->output = new NullOutput;
33+
}
3034

3135
/**
3236
* Set the console output implementation.
@@ -133,7 +137,9 @@ public function showStatus(): self
133137
];
134138
})->toArray();
135139

136-
$this->output->table($headers, $rows);
140+
if ($this->output instanceof OutputStyle) {
141+
$this->output->table($headers, $rows);
142+
}
137143

138144
return $this;
139145
}

0 commit comments

Comments
 (0)