Skip to content

Commit

Permalink
chore: Update InstallCommand to use call method for vendor:publish …
Browse files Browse the repository at this point in the history
…and migrate commands (#660)

* chore: Update InstallCommand to use `call` method for vendor:publish and migrate commands

* chore: Update InstallCommand to use `call` method for vendor:publish and migrate commands

* chore: Update InstallCommand to use `call` method for vendor:publish and migrate commands

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia authored Jun 4, 2024
1 parent 7c069fa commit 31e7d31
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,23 @@
namespace FriendsOfHyperf\Telescope\Command;

use Hyperf\Command\Command;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

class InstallCommand extends Command
{
public function __construct(private ContainerInterface $container)
public function __construct()
{
parent::__construct('telescope:install');
}

public function handle()
{
/** @var \Symfony\Component\Console\Application $application */
$application = $this->container->get(\Hyperf\Contract\ApplicationInterface::class);
$application->setAutoExit(false);

$output = new NullOutput();

$input = new ArrayInput(['command' => 'vendor:publish', 'package' => 'friendsofhyperf/telescope']);
$exitCode = $application->run($input, $output);
if (! $exitCode) {
if (! $this->call('vendor:publish', ['package' => 'friendsofhyperf/telescope'])) {
$this->info('publish successfully');
} else {
$this->error('publish failed');
}

$input = new ArrayInput(['command' => 'migrate']);
$exitCode = $application->run($input, $output);
if (! $exitCode) {
if (! $this->call('migrate')) {
$this->info('migrate successfully');
} else {
$this->error('migrate failed');
Expand Down

0 comments on commit 31e7d31

Please sign in to comment.