forked from maidsafe/sn_browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
afterSign.js
43 lines (34 loc) · 1.25 KB
/
afterSign.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db
const fs = require( 'fs' );
const path = require( 'path' );
const electronNotarize = require( 'electron-notarize' );
const buildConfig = require( './builderConfig' );
const shouldNotarize = process.env.SHOULD_NOTARIZE;
module.exports = async function( parameters ) {
// Only notarize the app on Mac OS only & on CI.
if ( process.platform !== 'darwin' || !shouldNotarize ) {
return;
}
console.log( 'afterSign hook triggered', parameters );
// Same appId in electron-builder.
const { appId } = buildConfig;
const appPath = path.join(
parameters.appOutDir,
`${parameters.packager.appInfo.productFilename}.app`
);
if ( !fs.existsSync( appPath ) ) {
throw new Error( `Cannot find application at: ${appPath}` );
}
console.log( `Notarizing ${appId} found at ${appPath}` );
try {
await electronNotarize.notarize( {
appBundleId: appId,
appPath,
appleId: `${process.env.APPLE_ID}`,
appleIdPassword: `${process.env.APPLE_ID_PASSWORD}`
} );
} catch ( error ) {
console.error( error );
}
console.log( `Done notarizing ${appId}` );
};