mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const fs = require('node:fs')
|
|
const path = require('node:path')
|
|
|
|
async function main(context) {
|
|
const { appOutDir, targets } = context
|
|
const localeDir = appOutDir + '/locales/'
|
|
|
|
fs.readdir(localeDir, function (_err, files) {
|
|
if (!(files && files.length)) return
|
|
for (let i = 0, len = files.length; i < len; i++) {
|
|
if (!(files[i].startsWith('en') || files[i].startsWith('zh'))) {
|
|
fs.unlinkSync(localeDir + files[i])
|
|
}
|
|
}
|
|
})
|
|
const isZip = targets.some(target => target.name === 'zip' || target.name === '7z')
|
|
if (isZip) {
|
|
const portablePath = path.join(appOutDir, 'PORTABLE')
|
|
try {
|
|
fs.writeFileSync(portablePath, '')
|
|
console.log('Created portable marker file at', portablePath)
|
|
} catch (err) {
|
|
console.error('Error creating portable marker file:', err)
|
|
}
|
|
} else {
|
|
const fileToRemave = path.join(appOutDir, 'resources/7za.exe')
|
|
console.log('Checking for unnecessary 7za.exe at', fileToRemave)
|
|
if (fs.existsSync(fileToRemave)) {
|
|
try {
|
|
fs.unlinkSync(fileToRemave)
|
|
console.log('Removed unnecessary 7za.exe from', fileToRemave)
|
|
} catch (err) {
|
|
console.error('Error removing 7za.exe:', err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
exports.default = main
|