@@ -4,7 +4,9 @@ const common = require('../common');
44const fixtures = require ( '../common/fixtures' ) ;
55
66const { readFileSync } = require ( 'fs' ) ;
7- const { execFileSync } = require ( 'child_process' ) ;
7+ const {
8+ spawnSyncAndExitWithoutError,
9+ } = require ( '../common/child_process' ) ;
810
911function skipIfSingleExecutableIsNotSupported ( ) {
1012 if ( ! process . config . variables . single_executable_application )
@@ -45,38 +47,39 @@ function skipIfSingleExecutableIsNotSupported() {
4547
4648function injectAndCodeSign ( targetExecutable , resource ) {
4749 const postjectFile = fixtures . path ( 'postject-copy' , 'node_modules' , 'postject' , 'dist' , 'cli.js' ) ;
48- execFileSync ( process . execPath , [
50+ spawnSyncAndExitWithoutError ( process . execPath , [
4951 postjectFile ,
5052 targetExecutable ,
5153 'NODE_SEA_BLOB' ,
5254 resource ,
5355 '--sentinel-fuse' , 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2' ,
5456 ...process . platform === 'darwin' ? [ '--macho-segment-name' , 'NODE_SEA' ] : [ ] ,
55- ] ) ;
57+ ] , { } ) ;
5658
5759 if ( process . platform === 'darwin' ) {
58- execFileSync ( 'codesign' , [ '--sign' , '-' , targetExecutable ] ) ;
59- execFileSync ( 'codesign' , [ '--verify' , targetExecutable ] ) ;
60+ spawnSyncAndExitWithoutError ( 'codesign' , [ '--sign' , '-' , targetExecutable ] , { } ) ;
61+ spawnSyncAndExitWithoutError ( 'codesign' , [ '--verify' , targetExecutable ] , { } ) ;
6062 } else if ( process . platform === 'win32' ) {
6163 let signtoolFound = false ;
6264 try {
63- execFileSync ( 'where' , [ 'signtool' ] ) ;
65+ spawnSyncAndExitWithoutError ( 'where' , [ 'signtool' ] , { } ) ;
6466 signtoolFound = true ;
6567 } catch ( err ) {
6668 console . log ( err . message ) ;
6769 }
6870 if ( signtoolFound ) {
6971 let certificatesFound = false ;
72+ let stderr ;
7073 try {
71- execFileSync ( 'signtool' , [ 'sign' , '/fd' , 'SHA256' , targetExecutable ] ) ;
74+ ( { stderr } = spawnSyncAndExitWithoutError ( 'signtool' , [ 'sign' , '/fd' , 'SHA256' , targetExecutable ] , { } ) ) ;
7275 certificatesFound = true ;
7376 } catch ( err ) {
74- if ( ! / S i g n T o o l E r r o r : N o c e r t i f i c a t e s w e r e f o u n d t h a t m e t a l l t h e g i v e n c r i t e r i a / . test ( err ) ) {
77+ if ( ! / S i g n T o o l E r r o r : N o c e r t i f i c a t e s w e r e f o u n d t h a t m e t a l l t h e g i v e n c r i t e r i a / . test ( stderr ) ) {
7578 throw err ;
7679 }
7780 }
7881 if ( certificatesFound ) {
79- execFileSync ( 'signtool' , 'verify' , '/pa' , 'SHA256' , targetExecutable ) ;
82+ spawnSyncAndExitWithoutError ( 'signtool' , 'verify' , '/pa' , 'SHA256' , targetExecutable , { } ) ;
8083 }
8184 }
8285 }
0 commit comments