()
| 34 | } |
| 35 | |
| 36 | function main() { |
| 37 | if (process.platform !== 'win32') { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | const localAppData = |
| 42 | process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'); |
| 43 | const cacheRoot = path.join(localAppData, 'electron-builder', 'Cache', 'winCodeSign', CACHE_VERSION); |
| 44 | |
| 45 | if (cacheIsReady(cacheRoot)) { |
| 46 | console.log('winCodeSign cache ready:', cacheRoot); |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | console.log('Pre-populating winCodeSign cache (avoids Windows symlink extraction error)...'); |
| 51 | |
| 52 | const tempRoot = path.join(os.tmpdir(), `winCodeSign-cache-${Date.now()}`); |
| 53 | const zipPath = path.join(tempRoot, 'winCodeSign.zip'); |
| 54 | const extractDir = path.join(tempRoot, 'extract'); |
| 55 | const archiveRoot = path.join(extractDir, 'electron-builder-binaries-winCodeSign-2.6.0', 'winCodeSign'); |
| 56 | |
| 57 | fs.mkdirSync(tempRoot, { recursive: true }); |
| 58 | |
| 59 | const ps = [ |
| 60 | `$ErrorActionPreference = 'Stop'`, |
| 61 | `New-Item -ItemType Directory -Force -Path '${extractDir.replace(/'/g, "''")}' | Out-Null`, |
| 62 | `Invoke-WebRequest -Uri '${ZIP_URL}' -OutFile '${zipPath.replace(/'/g, "''")}'`, |
| 63 | `Expand-Archive -Path '${zipPath.replace(/'/g, "''")}' -DestinationPath '${extractDir.replace(/'/g, "''")}' -Force`, |
| 64 | `if (-not (Test-Path '${archiveRoot.replace(/'/g, "''")}')) { throw "Unexpected archive layout: ${archiveRoot.replace(/'/g, "''")}" }`, |
| 65 | `New-Item -ItemType Directory -Force -Path '${cacheRoot.replace(/'/g, "''")}' | Out-Null`, |
| 66 | `Copy-Item -Path '${archiveRoot.replace(/'/g, "''")}\\*' -Destination '${cacheRoot.replace(/'/g, "''")}' -Recurse -Force`, |
| 67 | ].join('; '); |
| 68 | |
| 69 | try { |
| 70 | runPowerShell(ps); |
| 71 | if (!cacheIsReady(cacheRoot)) { |
| 72 | console.error('winCodeSign cache population failed:', cacheRoot); |
| 73 | process.exit(1); |
| 74 | } |
| 75 | console.log('winCodeSign cache populated:', cacheRoot); |
| 76 | } finally { |
| 77 | try { |
| 78 | fs.rmSync(tempRoot, { recursive: true, force: true }); |
| 79 | } catch { |
| 80 | /* non-fatal */ |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | main(); |
no test coverage detected