我有一个处理公证的签字后模块。
我只想在构建mac应用程序时执行它。
我的package.json就是这样。
"scripts": {
"build:mac": "node .electron-vue/build.js && electron-builder --mac",
"build:win": "node .electron-vue/build.js && electron-builder --win --x64 --ia32",
},
"build": {
"mac": {
"hardenedRuntime": true,
"entitlements": "./notarlization/entitlement.plist",
"entitlementsInherit": "./notarlization/entitlement.plist"
},
"afterSign": "./notarlization/after-sign.js"
}
我的签后模块就是这样。
module.exports = async () => {
if (process.platform === 'darwin') {
console.log(`公証通過申請中...`)
try {
await notarize({
appBundleId,
appPath,
appleId,
appleIdPassword,
ascProvider
})
console.log('公証通過完了')
} catch (error) {
console.log('公証通過失敗: ', error)
}
}
}
实际上,它可以正常工作。
因为我在macOS中构建了Mac应用程序,而在WinOS中构建了Win应用程序。
但是我认为if (process.platform === 'darwin') {}
不是傻瓜。
我想在package.json中做类似的事情。
有人知道该怎么做吗?
在electron-builder documentation中,您可以在页面底部看到您可以在afterSign
配置对象“ ... 以及所有特定于平台的常用选项。”中使用mac
。认为这是最好的方法。
否则,您将看到其他可用选项here