Files
LoveLiveMusicPlayer-Next/scripts/patch-electron-dev-name.mjs
2026-08-08 22:45:23 +08:00

37 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 开发态跑的是 node_modules 里的 Electron.app菜单栏名称来自 Info.plist。
* 把 CFBundleName / CFBundleDisplayName 改成产品名(仅 macOSnpm i 后需再跑一次)。
*/
import { createRequire } from 'module'
import { execFileSync } from 'child_process'
import { existsSync } from 'fs'
import { dirname, join } from 'path'
import { platform } from 'os'
const APP_NAME = 'LoveLiveMusicPlayer'
if (platform() !== 'darwin') {
process.exit(0)
}
const require = createRequire(import.meta.url)
let electronBinary
try {
electronBinary = require('electron')
} catch {
process.exit(0)
}
const plist = join(dirname(String(electronBinary)), '..', 'Info.plist')
if (!existsSync(plist)) {
console.warn('[patch-electron] Info.plist 未找到:', plist)
process.exit(0)
}
for (const key of ['CFBundleName', 'CFBundleDisplayName']) {
execFileSync('plutil', ['-replace', key, '-string', APP_NAME, plist])
}
// 促使 Launch Services 刷新缓存
execFileSync('touch', [join(dirname(plist), '..')])
console.log(`[patch-electron] 开发态应用名 → ${APP_NAME}`)