Files
2026-10-11 07:55:36 -07:00

39 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
'use strict'
// Force electron-forge to REPACKAGE from scratch. electron-packager skips
// packaging when `out/<name>-win32-x64` already exists, silently reusing a stale
// app.asar — including its OLD package.json version. That's how a bumped root
// version (e.g. 0.17.0) still shipped a nuspec with the previous version and made
// Squirrel's releasify crash on an ancient value. Removing the packaged dir (and
// the maker output) before every packaged build guarantees the current version.
const fs = require('fs')
const path = require('path')
const outDir = path.join(__dirname, '..', 'out')
// The maker output.
try {
fs.rmSync(path.join(outDir, 'make'), { recursive: true, force: true })
console.log('[clean] removed out/make')
} catch (e) {
console.warn(`[clean] out/make: ${(e && e.message) || e}`)
}
// Every packaged app dir, whatever the platform/arch (CrossSound-win32-x64,
// CrossSound-darwin-arm64, CrossSound-linux-x64, …) — electron-packager skips
// packaging when the dir already exists and silently reuses a stale app.asar
// (old version → the Squirrel releasify crash). Wipe them all so every OS
// repackages from scratch.
try {
for (const name of fs.readdirSync(outDir)) {
// startsWith('CrossSound') — not 'CrossSound-' — so the renamed macOS debug
// dir (CrossSoundDebugging-darwin-arm64) is wiped too.
if (name.startsWith('CrossSound')) {
fs.rmSync(path.join(outDir, name), { recursive: true, force: true })
console.log(`[clean] removed out/${name}`)
}
}
} catch (_) {
// out/ doesn't exist yet — nothing to clean.
}