mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const electronNotarize = require('electron-notarize');
|
|
const appConfig = require('../config').appConfig();
|
|
|
|
// See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db
|
|
module.exports = async function(params) {
|
|
// Only notarize the app on Mac OS only.
|
|
if (process.platform !== 'darwin') {
|
|
return;
|
|
}
|
|
|
|
// Same appId in electron-builder.
|
|
const { appId } = appConfig;
|
|
|
|
const appName = `${params.packager.appInfo.productFilename}.app`;
|
|
const appPath = path.join(params.appOutDir, appName);
|
|
if (!fs.existsSync(appPath)) {
|
|
throw new Error(`Cannot find application at: ${appName}`);
|
|
}
|
|
|
|
const args = {
|
|
appBundleId: appId,
|
|
appPath: appPath,
|
|
appleId: process.env.APPLE_ID,
|
|
appleIdPassword: process.env.APPLE_ID_PASSWORD,
|
|
};
|
|
|
|
if (!process.env.APPLE_ID) {
|
|
console.log('[aftersign] APPLE_ID env variable not set. Skipping notarization');
|
|
return;
|
|
}
|
|
|
|
if (!process.env.APPLE_ID_PASSWORD) {
|
|
console.log('[aftersign] APPLE_ID env variable not set. Skipping notarization');
|
|
return;
|
|
}
|
|
|
|
console.log(`[afterSign] Notarizing ${appName} (${appId})`);
|
|
|
|
try {
|
|
await electronNotarize.notarize(args);
|
|
} catch (err) {
|
|
console.error(err);
|
|
process.exit(1);
|
|
}
|
|
};
|