@@ -12,6 +12,7 @@ const child_process = require('child_process');
12
12
const path = require ( 'path' ) ;
13
13
const fs = require ( 'fs' ) ;
14
14
const os = require ( 'os' ) ;
15
+ const { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
15
16
16
17
const nodeBinary = process . execPath ;
17
18
@@ -42,30 +43,26 @@ fs.copyFileSync(
42
43
nodeBinary ,
43
44
appExecutablePath ) ;
44
45
45
-
46
46
// Sign the app bundle with sandbox entitlements:
47
- assert . strictEqual (
48
- child_process . spawnSync ( '/usr/bin/codesign' , [
49
- '--entitlements ', fixtures . path (
50
- 'macos-app-sandbox' , 'node_sandboxed.entitlements' ) ,
51
- '--force' , '-s' , '- ',
52
- appBundlePath ,
53
- ] ) . status ,
54
- 0 ) ;
47
+ spawnSyncAndExitWithoutError ( '/usr/bin/codesign' , [
48
+ '--entitlements' ,
49
+ fixtures . path ( 'macos-app-sandbox ', 'node_sandboxed.entitlements' ) ,
50
+ '--force' ,
51
+ '-s ',
52
+ '-' ,
53
+ appBundlePath ,
54
+ ] ) ;
55
55
56
56
// Sandboxed app shouldn't be able to read the home dir
57
- assert . notStrictEqual (
58
- child_process . spawnSync ( appExecutablePath , [
59
- '-e' , ' fs.readdirSync(process.argv[1])', os . homedir ( ) ,
60
- ] ) . status ,
61
- 0 ) ;
57
+ spawnSyncAndExitWithoutError ( appExecutablePath , [
58
+ '-e' ,
59
+ ' fs.readdirSync(process.argv[1])',
60
+ os . homedir ( ) ,
61
+ ] ) ;
62
62
63
63
if ( process . stdin . isTTY ) {
64
64
// Run the sandboxed node instance with inherited tty stdin
65
- const spawnResult = child_process . spawnSync (
66
- appExecutablePath , [ '-e' , '' ] ,
67
- { stdio : 'inherit' }
68
- ) ;
69
-
70
- assert . strictEqual ( spawnResult . signal , null ) ;
65
+ spawnSyncAndExitWithoutError ( appExecutablePath , [ '-e' , '' ] , {
66
+ stdio : 'inherit' ,
67
+ } ) ;
71
68
}
0 commit comments