31 lines
1.3 KiB
JavaScript
Executable File
31 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict'
|
|
// Build icons/icon.icns (the macOS app icon) from icons/CrossSound.svg. macOS-only:
|
|
// scripts/gen-icns.swift draws every size of the Apple .iconset from the vector
|
|
// (white mark on a tile of the SVG's colour, sized to Apple's icon grid so it
|
|
// matches other Dock icons), then the system `iconutil` packs it.
|
|
// Regenerate after changing the SVG: `node scripts/gen-icns.js`.
|
|
const fs = require('fs')
|
|
const os = require('os')
|
|
const path = require('path')
|
|
const { execFileSync } = require('child_process')
|
|
|
|
if (process.platform !== 'darwin') {
|
|
console.error('[gen-icns] needs macOS (swift + iconutil) — run it on the Mac')
|
|
process.exit(1)
|
|
}
|
|
|
|
const iconsDir = path.join(__dirname, '..', 'icons')
|
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'crosssound-icns-'))
|
|
const iconset = path.join(tmp, 'CrossSound.iconset')
|
|
fs.mkdirSync(iconset)
|
|
try {
|
|
execFileSync('swift', [path.join(__dirname, 'gen-icns.swift'), path.join(iconsDir, 'CrossSound.svg'), iconset],
|
|
{ stdio: 'inherit' })
|
|
const out = path.join(iconsDir, 'icon.icns')
|
|
execFileSync('iconutil', ['-c', 'icns', iconset, '-o', out], { stdio: 'inherit' })
|
|
console.log(`[gen-icns] wrote icons/icon.icns — ${fs.readdirSync(iconset).length} images, ${fs.statSync(out).size} bytes`)
|
|
} finally {
|
|
fs.rmSync(tmp, { recursive: true, force: true })
|
|
}
|