Skip to content

Commit ab2fd13

Browse files
authored
Use Prompts to request Platform when not provided (#92)
1 parent 0a00d70 commit ab2fd13

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/Commands/BuildCommand.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
use Native\Electron\Concerns\LocatesPhpBinary;
99
use Native\Electron\Facades\Updater;
1010

11+
use function Laravel\Prompts\select;
12+
1113
class BuildCommand extends Command
1214
{
1315
use LocatesPhpBinary;
1416

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

1719
public function handle(): void
1820
{
@@ -23,9 +25,17 @@ public function handle(): void
2325
echo $output;
2426
});
2527

28+
if (! $os = $this->argument('os')) {
29+
$os = select(
30+
label: 'Please select the operating system to build for',
31+
options: ['win', 'linux', 'mac', 'all'],
32+
default: $this->getDefaultOs(),
33+
);
34+
}
35+
2636
$buildCommand = 'npm run build';
27-
if ($this->argument('os')) {
28-
$buildCommand .= ':'.$this->argument('os');
37+
if ($os) {
38+
$buildCommand .= ':'.$os;
2939
}
3040

3141
Process::path(__DIR__.'/../../resources/js/')
@@ -57,4 +67,14 @@ protected function getEnvironmentVariables(): array
5767
Updater::environmentVariables(),
5868
);
5969
}
70+
71+
protected function getDefaultOs(): string
72+
{
73+
return match (PHP_OS_FAMILY) {
74+
'Windows' => 'win',
75+
'Darwin' => 'mac',
76+
'Linux' => 'linux',
77+
default => 'all',
78+
};
79+
}
6080
}

0 commit comments

Comments
 (0)