lx-music-desktop/build-config/build-after-pack.js

26 lines
853 B
JavaScript
Raw Permalink Normal View History

2022-10-29 03:36:35 +00:00
const fs = require('fs').promises
// https://github.com/electron-userland/electron-builder/issues/4630
// https://github.com/electron-userland/electron-builder/issues/4630#issuecomment-782020139
module.exports = async(context) => {
const { electronPlatformName, appOutDir } = context
if (electronPlatformName !== 'darwin') return
const {
productFilename,
info: {
_metadata: { macLanguagesInfoPlistStrings },
},
} = context.packager.appInfo
const resPath = `${appOutDir}/${productFilename}.app/Contents/Resources`
// 创建APP语言包文件
2023-08-30 06:30:47 +00:00
return Promise.all(
2022-10-29 03:36:35 +00:00
Object.entries(macLanguagesInfoPlistStrings).map(([lang, config]) => {
let infos = Object.entries(config).map(([k, v]) => `"${k}" = "${v}";`).join('\n')
return fs.writeFile(`${resPath}/${lang}.lproj/InfoPlist.strings`, infos)
}),
)
}