11# Build Windows package
22# This script handles the electron-builder failures gracefully
33
4- Write-Host " `n ========================================" - ForegroundColor Cyan
5- Write-Host " Building Windows Package" - ForegroundColor Cyan
6- Write-Host " ========================================`n " - ForegroundColor Cyan
4+ Write-Host " `n ========================================" - ForegroundColor Cyan
5+ Write-Host ' Building Windows Package' - ForegroundColor Cyan
6+ Write-Host ' ========================================' - ForegroundColor Cyan
7+ Write-Host ' '
78
89# Set environment variables
910$env: NODE_ENV = " production"
1011$env: ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES = " true"
1112
1213# Run electron-builder with --dir to create win-unpacked
1314# We ignore the exit code because it may fail on winCodeSign but still create win-unpacked
14- Write-Host " Running electron-builder..." - ForegroundColor Yellow
15+ Write-Host ' Running electron-builder...' - ForegroundColor Yellow
1516
1617try {
1718 npx electron- builder -- win -- x64 -- dir 2>&1 | Out-Host
1819} catch {
1920 Write-Host " `n electron-builder encountered errors" - ForegroundColor Yellow
2021}
2122
22- Write-Host " `n Checking if win-unpacked was created..." - ForegroundColor Yellow
23+ Write-Host ' Checking if win-unpacked was created...' - ForegroundColor Yellow
24+ Write-Host ' '
2325
2426# Check if win-unpacked exists
2527$scriptPath = Split-Path - Parent $MyInvocation.MyCommand.Path
@@ -28,23 +30,25 @@ $distPath = Join-Path -Path $projectRoot -ChildPath "dist"
2830$unpackedPath = Join-Path - Path $distPath - ChildPath " win-unpacked"
2931
3032if (Test-Path $unpackedPath ) {
31- Write-Host " ✓ win-unpacked directory found" - ForegroundColor Green
32- Write-Host " Proceeding to create ZIP package...`n " - ForegroundColor Green
33+ Write-Host ' ✓ win-unpacked directory found' - ForegroundColor Green
34+ Write-Host ' Proceeding to create ZIP package...' - ForegroundColor Green
35+ Write-Host ' '
3336
3437 # Run the pack script
3538 $packScript = Join-Path - Path $scriptPath - ChildPath " pack-windows.js"
3639 node $packScript
3740
3841 if ($LASTEXITCODE -eq 0 ) {
39- Write-Host " `n Windows package built successfully!`n " - ForegroundColor Green
42+ Write-Host " `n Windows package built successfully!" - ForegroundColor Green
43+ Write-Host ' '
4044 exit 0
4145 } else {
42- Write-Host " `n ZIP packaging failed`n " - ForegroundColor Red
46+ Write-Host " `n ZIP packaging failed" - ForegroundColor Red
47+ Write-Host ' '
4348 exit 1
4449 }
4550} else {
46- Write-Host " `n win-unpacked directory not found at: $unpackedPath " - ForegroundColor Red
47- Write-Host " electron-builder failed to create the unpacked directory" - ForegroundColor Red
51+ Write-Host ( " `n win-unpacked directory not found at: {0} " -f $unpackedPath ) - ForegroundColor Red
52+ Write-Host ' electron-builder failed to create the unpacked directory' - ForegroundColor Red
4853 exit 1
4954}
50-
0 commit comments