Skip to content

Commit 9d42e65

Browse files
authored
Fix publish command (#93)
* Fix publish command * Fix styling --------- Co-authored-by: simonhamp <[email protected]>
1 parent e897c65 commit 9d42e65

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/Commands/PublishCommand.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PublishCommand extends Command
1212
{
1313
use LocatesPhpBinary;
1414

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

1717
public function handle(): void
1818
{
@@ -30,16 +30,19 @@ public function handle(): void
3030
echo $output;
3131
});
3232

33-
$buildCommand = 'npm run build';
34-
if ($this->argument('os')) {
35-
$buildCommand .= ':'.$this->argument('os');
33+
if (! $os = $this->argument('os')) {
34+
$os = select(
35+
label: 'Please select the operating system to build for',
36+
options: ['win', 'linux', 'mac', 'all'],
37+
default: $this->getDefaultOs(),
38+
);
3639
}
3740

3841
Process::path(__DIR__.'/../../resources/js/')
3942
->env($this->getEnvironmentVariables())
4043
->forever()
4144
->tty(PHP_OS_FAMILY != 'Windows' && ! $this->option('no-interaction'))
42-
->run($buildCommand, function (string $type, string $output) {
45+
->run("npm run publish:{$os}", function (string $type, string $output) {
4346
echo $output;
4447
});
4548
}
@@ -62,4 +65,14 @@ protected function getEnvironmentVariables(): array
6265
Updater::environmentVariables(),
6366
);
6467
}
68+
69+
protected function getDefaultOs(): string
70+
{
71+
return match (PHP_OS_FAMILY) {
72+
'Windows' => 'win',
73+
'Darwin' => 'mac',
74+
'Linux' => 'linux',
75+
default => 'all',
76+
};
77+
}
6578
}

0 commit comments

Comments
 (0)