# Monitor electron-builder cache and fix symlink extraction errors in real-time $cacheDir = "$env:LOCALAPPDATA\electron-builder\Cache\winCodeSign" $maxWait = 120 # Wait up to 2 minutes $checkInterval = 0.5 # Check every 500ms Write-Host "Monitoring for winCodeSign extraction..." for ($i = 0; $i -lt ($maxWait * 2); $i++) { Start-Sleep -Milliseconds ($checkInterval * 1000) # Look for .7z files that were just downloaded $archives = Get-ChildItem -Path $cacheDir -Filter "*.7z" -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -gt (Get-Date).AddMinutes(-5) } | Sort-Object LastWriteTime -Descending foreach ($archive in $archives) { # Check for extraction directories (random numbers) $extractDirs = Get-ChildItem -Path $cacheDir -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^\d+$' -and $_.LastWriteTime -gt (Get-Date).AddMinutes(-2) } foreach ($dir in $extractDirs) { $symlinks = @( "darwin\10.12\lib\libcrypto.dylib", "darwin\10.12\lib\libssl.dylib" ) $needsFix = $false foreach ($symlink in $symlinks) { $symlinkPath = Join-Path $dir.FullName $symlink if (-not (Test-Path $symlinkPath)) { $needsFix = $true break } } if ($needsFix) { Write-Host "Fixing symlinks in: $($dir.Name)" foreach ($symlink in $symlinks) { $symlinkPath = Join-Path $dir.FullName $symlink $symlinkDir = Split-Path $symlinkPath -Parent if (-not (Test-Path $symlinkDir)) { New-Item -ItemType Directory -Path $symlinkDir -Force | Out-Null } if (-not (Test-Path $symlinkPath)) { New-Item -ItemType File -Path $symlinkPath -Force | Out-Null } } Write-Host "Fixed symlinks in: $($dir.Name)" } } } } Write-Host "Monitoring complete" exit 0