Skip to content

Commit e9caa32

Browse files
committed
Implement signature option for asset-build
- Specify `--assets` to build assets - If --asset-build is unspecified, we'll try to run `npm run build`. - A specific build command can be specified like so `--asset-build=my-build-command`
1 parent 5305c19 commit e9caa32

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

resources/js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Laravel",
2+
"name": "NativePHP",
33
"version": "1.0.0",
44
"description": "A NativePHP Electron application",
55
"main": "./out/main/index.js",
@@ -105,4 +105,4 @@
105105
"#plugin": "./electron-plugin/dist/index.js"
106106
},
107107
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
108-
}
108+
}

src/Commands/BuildCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class BuildCommand extends Command
2121
protected $signature = 'native:build
2222
{os? : The operating system to build for (all, linux, mac, win)}
2323
{arch? : The Processor Architecture to build for (x64, x86, arm64)}
24-
{--publish : to publish the app}';
24+
{--publish : to publish the app}
25+
{--assets : to build the project assets}
26+
{--asset-build=build : The NPM script to run to build your project assets}';
2527

2628
protected $availableOs = ['win', 'linux', 'mac', 'all'];
2729

@@ -41,7 +43,9 @@ public function handle(): void
4143
echo $output;
4244
});
4345

44-
$this->checkAndBuildProjectAssets(null);
46+
if ($this->option('assets')) {
47+
$this->checkAndBuildProjectAssets($this->option('asset-build'));
48+
}
4549

4650
$os = $this->selectOs($this->argument('os'));
4751

src/Traits/ManagesAssetBuilding.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ public function checkAndBuildProjectAssets(?string $buildCommand): ?ProcessResul
4646
}
4747

4848
if (! isset($scripts[$buildCommand])) {
49-
$this->error('Invalid script selected... Continuing...');
49+
// We might get here if the script wasn't defined and the default was used.
50+
// We can try to prompt the user again.
51+
$buildCommand = $this->promptForAssetBuildCommand($scripts);
5052

51-
return null;
53+
if (! isset($scripts[$buildCommand])) {
54+
$this->error('Invalid script selected. Exiting…');
55+
return null;
56+
}
5257
}
5358

5459
$this->info('Building project assets…');

0 commit comments

Comments
 (0)