|
6 | 6 | use Illuminate\Console\Command;
|
7 | 7 | use Illuminate\Filesystem\Filesystem;
|
8 | 8 | use Illuminate\Support\Str;
|
| 9 | +use RuntimeException; |
9 | 10 | use Symfony\Component\Process\PhpExecutableFinder;
|
10 | 11 | use Symfony\Component\Process\Process;
|
11 | 12 |
|
@@ -237,9 +238,10 @@ protected function installLivewireStack()
|
237 | 238 | $this->installLivewireTeamStack();
|
238 | 239 | }
|
239 | 240 |
|
| 241 | + $this->runCommands(['npm install', 'npm run build']); |
| 242 | + |
240 | 243 | $this->line('');
|
241 | 244 | $this->components->info('Livewire scaffolding installed successfully.');
|
242 |
| - $this->components->warn('Please execute the [npm install && npm run build] commands to build your assets.'); |
243 | 245 | }
|
244 | 246 |
|
245 | 247 | /**
|
@@ -425,9 +427,10 @@ protected function installInertiaStack()
|
425 | 427 | $this->installInertiaSsrStack();
|
426 | 428 | }
|
427 | 429 |
|
| 430 | + $this->runCommands(['npm install', 'npm run build']); |
| 431 | + |
428 | 432 | $this->line('');
|
429 | 433 | $this->components->info('Inertia scaffolding installed successfully.');
|
430 |
| - $this->components->warn('Please execute the [npm install && npm run build] commands to build your assets.'); |
431 | 434 | }
|
432 | 435 |
|
433 | 436 | /**
|
@@ -714,4 +717,27 @@ protected function phpBinary()
|
714 | 717 | {
|
715 | 718 | return (new PhpExecutableFinder())->find(false) ?: 'php';
|
716 | 719 | }
|
| 720 | + |
| 721 | + /** |
| 722 | + * Run the given commands. |
| 723 | + * |
| 724 | + * @param array $commands |
| 725 | + * @return void |
| 726 | + */ |
| 727 | + protected function runCommands($commands) |
| 728 | + { |
| 729 | + $process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null); |
| 730 | + |
| 731 | + if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { |
| 732 | + try { |
| 733 | + $process->setTty(true); |
| 734 | + } catch (RuntimeException $e) { |
| 735 | + $this->output->writeln(' <bg=yellow;fg=black> WARN </> '.$e->getMessage().PHP_EOL); |
| 736 | + } |
| 737 | + } |
| 738 | + |
| 739 | + $process->run(function ($type, $line) { |
| 740 | + $this->output->write(' '.$line); |
| 741 | + }); |
| 742 | + } |
717 | 743 | }
|
0 commit comments