8
8
use Native \Electron \Concerns \LocatesPhpBinary ;
9
9
use Native \Electron \Facades \Updater ;
10
10
11
+ use function Laravel \Prompts \select ;
12
+
11
13
class BuildCommand extends Command
12
14
{
13
15
use LocatesPhpBinary;
14
16
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)} ' ;
16
18
17
19
public function handle (): void
18
20
{
@@ -23,9 +25,17 @@ public function handle(): void
23
25
echo $ output ;
24
26
});
25
27
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
+
26
36
$ buildCommand = 'npm run build ' ;
27
- if ($ this -> argument ( ' os ' ) ) {
28
- $ buildCommand .= ': ' .$ this -> argument ( ' os ' ) ;
37
+ if ($ os ) {
38
+ $ buildCommand .= ': ' .$ os ;
29
39
}
30
40
31
41
Process::path (__DIR__ .'/../../resources/js/ ' )
@@ -57,4 +67,14 @@ protected function getEnvironmentVariables(): array
57
67
Updater::environmentVariables (),
58
68
);
59
69
}
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
+ }
60
80
}
0 commit comments