Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use RuntimeException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -237,9 +238,10 @@ protected function installLivewireStack()
$this->installLivewireTeamStack();
}

$this->runCommands(['npm install', 'npm run build']);

$this->line('');
$this->components->info('Livewire scaffolding installed successfully.');
$this->components->warn('Please execute the [npm install && npm run build] commands to build your assets.');
}

/**
Expand Down Expand Up @@ -425,9 +427,10 @@ protected function installInertiaStack()
$this->installInertiaSsrStack();
}

$this->runCommands(['npm install', 'npm run build']);

$this->line('');
$this->components->info('Inertia scaffolding installed successfully.');
$this->components->warn('Please execute the [npm install && npm run build] commands to build your assets.');
}

/**
Expand Down Expand Up @@ -714,4 +717,27 @@ protected function phpBinary()
{
return (new PhpExecutableFinder())->find(false) ?: 'php';
}

/**
* Run the given commands.
*
* @param array $commands
* @return void
*/
protected function runCommands($commands)
{
$process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null);

if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
try {
$process->setTty(true);
} catch (RuntimeException $e) {
$this->output->writeln(' <bg=yellow;fg=black> WARN </> '.$e->getMessage().PHP_EOL);
}
}

$process->run(function ($type, $line) {
$this->output->write(' '.$line);
});
}
}