Skip to content

Commit

Permalink
Fix publish command (#93)
Browse files Browse the repository at this point in the history
* Fix publish command

* Fix styling

---------

Co-authored-by: simonhamp <[email protected]>
  • Loading branch information
simonhamp and simonhamp authored May 6, 2024
1 parent e897c65 commit 9d42e65
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PublishCommand extends Command
{
use LocatesPhpBinary;

protected $signature = 'native:publish {os=all : The operating system to build for (all, linux, mac, windows)}';
protected $signature = 'native:publish {os? : The operating system to build for (linux, mac, win)}';

public function handle(): void
{
Expand All @@ -30,16 +30,19 @@ public function handle(): void
echo $output;
});

$buildCommand = 'npm run build';
if ($this->argument('os')) {
$buildCommand .= ':'.$this->argument('os');
if (! $os = $this->argument('os')) {
$os = select(

Check failure on line 34 in src/Commands/PublishCommand.php

View workflow job for this annotation

GitHub Actions / phpstan

Function select not found.
label: 'Please select the operating system to build for',
options: ['win', 'linux', 'mac', 'all'],
default: $this->getDefaultOs(),
);
}

Process::path(__DIR__.'/../../resources/js/')
->env($this->getEnvironmentVariables())
->forever()
->tty(PHP_OS_FAMILY != 'Windows' && ! $this->option('no-interaction'))
->run($buildCommand, function (string $type, string $output) {
->run("npm run publish:{$os}", function (string $type, string $output) {
echo $output;
});
}
Expand All @@ -62,4 +65,14 @@ protected function getEnvironmentVariables(): array
Updater::environmentVariables(),

Check failure on line 65 in src/Commands/PublishCommand.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined static method Native\Electron\Facades\Updater::environmentVariables().
);
}

protected function getDefaultOs(): string
{
return match (PHP_OS_FAMILY) {
'Windows' => 'win',
'Darwin' => 'mac',
'Linux' => 'linux',
default => 'all',
};
}
}

0 comments on commit 9d42e65

Please sign in to comment.