@@ -15,14 +15,42 @@ const isEmpty = v => !v || v.length === 0;
15
15
16
16
const { execSync } = require ( 'node:child_process' ) ;
17
17
18
+ function runCommandWithExitCode ( command ) {
19
+ try {
20
+ const output = execSync ( command , { stdio : 'pipe' } ) ;
21
+ return { success : true , output : output . toString ( ) . trim ( ) } ;
22
+ } catch ( error ) {
23
+ return { success : false , code : error . status , message : error . stderr . toString ( ) . trim ( ) } ;
24
+ }
25
+ }
26
+
18
27
exports . default = async function notarizing ( context ) {
19
28
const { electronPlatformName, appOutDir } = context ;
20
29
if ( electronPlatformName !== 'darwin' ) {
21
30
return ;
22
31
}
23
- log ( 'Notarizing mac application' ) ;
24
32
25
33
const appName = context . packager . appInfo . productFilename ;
34
+
35
+ const appPath = `${ appOutDir } /${ appName } .app` ;
36
+ const zipPath = `${ appOutDir } /${ appName } .zip` ;
37
+
38
+ const verifyCheck = runCommandWithExitCode ( `codesign --verify --deep --strict "${ appPath } "` ) ;
39
+ if ( ! verifyCheck . success ) {
40
+ if ( verifyCheck . code === 1 ) {
41
+ console . error ( `Signature is invalid for app "${ appPath } ".` ) ;
42
+ } else if ( verifyCheck . code === 2 ) {
43
+ console . error ( `"${ appPath } " is not signed.` ) ;
44
+ } else {
45
+ console . error ( `Error (${ verifyCheck . code } ): ${ verifyCheck . message } for app: "${ appPath } "` ) ;
46
+ }
47
+ console . warn ( 'skipping notarization step' ) ;
48
+ return ;
49
+ }
50
+
51
+ log ( `"${ appPath } " signature is valid.` ) ;
52
+ log ( 'Notarizing mac application' ) ;
53
+
26
54
const { SIGNING_APPLE_ID , SIGNING_APP_PASSWORD , SIGNING_TEAM_ID } = process . env ;
27
55
28
56
if ( isEmpty ( SIGNING_APPLE_ID ) ) {
@@ -40,9 +68,6 @@ exports.default = async function notarizing(context) {
40
68
return ;
41
69
}
42
70
43
- const appPath = `${ appOutDir } /${ appName } .app` ;
44
- const zipPath = `${ appOutDir } /${ appName } .zip` ;
45
-
46
71
console . log (
47
72
execSync ( `ditto -c -k --sequesterRsrc --keepParent "${ appPath } " "${ zipPath } "` , {
48
73
encoding : 'utf8' ,
0 commit comments