@@ -4,7 +4,9 @@ const common = require('../common');
4
4
const fixtures = require ( '../common/fixtures' ) ;
5
5
6
6
const { readFileSync } = require ( 'fs' ) ;
7
- const { execFileSync } = require ( 'child_process' ) ;
7
+ const {
8
+ spawnSyncAndExitWithoutError,
9
+ } = require ( '../common/child_process' ) ;
8
10
9
11
function skipIfSingleExecutableIsNotSupported ( ) {
10
12
if ( ! process . config . variables . single_executable_application )
@@ -45,38 +47,39 @@ function skipIfSingleExecutableIsNotSupported() {
45
47
46
48
function injectAndCodeSign ( targetExecutable , resource ) {
47
49
const postjectFile = fixtures . path ( 'postject-copy' , 'node_modules' , 'postject' , 'dist' , 'cli.js' ) ;
48
- execFileSync ( process . execPath , [
50
+ spawnSyncAndExitWithoutError ( process . execPath , [
49
51
postjectFile ,
50
52
targetExecutable ,
51
53
'NODE_SEA_BLOB' ,
52
54
resource ,
53
55
'--sentinel-fuse' , 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2' ,
54
56
...process . platform === 'darwin' ? [ '--macho-segment-name' , 'NODE_SEA' ] : [ ] ,
55
- ] ) ;
57
+ ] , { } ) ;
56
58
57
59
if ( process . platform === 'darwin' ) {
58
- execFileSync ( 'codesign' , [ '--sign' , '-' , targetExecutable ] ) ;
59
- execFileSync ( 'codesign' , [ '--verify' , targetExecutable ] ) ;
60
+ spawnSyncAndExitWithoutError ( 'codesign' , [ '--sign' , '-' , targetExecutable ] , { } ) ;
61
+ spawnSyncAndExitWithoutError ( 'codesign' , [ '--verify' , targetExecutable ] , { } ) ;
60
62
} else if ( process . platform === 'win32' ) {
61
63
let signtoolFound = false ;
62
64
try {
63
- execFileSync ( 'where' , [ 'signtool' ] ) ;
65
+ spawnSyncAndExitWithoutError ( 'where' , [ 'signtool' ] , { } ) ;
64
66
signtoolFound = true ;
65
67
} catch ( err ) {
66
68
console . log ( err . message ) ;
67
69
}
68
70
if ( signtoolFound ) {
69
71
let certificatesFound = false ;
72
+ let stderr ;
70
73
try {
71
- execFileSync ( 'signtool' , [ 'sign' , '/fd' , 'SHA256' , targetExecutable ] ) ;
74
+ ( { stderr } = spawnSyncAndExitWithoutError ( 'signtool' , [ 'sign' , '/fd' , 'SHA256' , targetExecutable ] , { } ) ) ;
72
75
certificatesFound = true ;
73
76
} 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 ) ) {
75
78
throw err ;
76
79
}
77
80
}
78
81
if ( certificatesFound ) {
79
- execFileSync ( 'signtool' , 'verify' , '/pa' , 'SHA256' , targetExecutable ) ;
82
+ spawnSyncAndExitWithoutError ( 'signtool' , 'verify' , '/pa' , 'SHA256' , targetExecutable , { } ) ;
80
83
}
81
84
}
82
85
}
0 commit comments