@@ -25,11 +25,10 @@ const path = require('path');
25
25
const fs = require ( 'fs' ) ;
26
26
const assert = require ( 'assert' ) ;
27
27
const os = require ( 'os' ) ;
28
- const child_process = require ( 'child_process' ) ;
28
+ const { exec , execSync , spawn , spawnSync } = require ( 'child_process' ) ;
29
29
const stream = require ( 'stream' ) ;
30
30
const util = require ( 'util' ) ;
31
31
const Timer = process . binding ( 'timer_wrap' ) . Timer ;
32
- const execSync = require ( 'child_process' ) . execSync ;
33
32
34
33
const testRoot = process . env . NODE_TEST_DIR ?
35
34
fs . realpathSync ( process . env . NODE_TEST_DIR ) : path . resolve ( __dirname , '..' ) ;
@@ -186,7 +185,7 @@ Object.defineProperty(exports, 'inFreeBSDJail', {
186
185
if ( inFreeBSDJail !== null ) return inFreeBSDJail ;
187
186
188
187
if ( exports . isFreeBSD &&
189
- child_process . execSync ( 'sysctl -n security.jail.jailed' ) . toString ( ) ===
188
+ execSync ( 'sysctl -n security.jail.jailed' ) . toString ( ) ===
190
189
'1\n' ) {
191
190
inFreeBSDJail = true ;
192
191
} else {
@@ -233,7 +232,7 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
233
232
234
233
if ( exports . isWindows ) opensslCli += '.exe' ;
235
234
236
- const opensslCmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
235
+ const opensslCmd = spawnSync ( opensslCli , [ 'version' ] ) ;
237
236
if ( opensslCmd . status !== 0 || opensslCmd . error !== undefined ) {
238
237
// openssl command cannot be executed
239
238
opensslCli = false ;
@@ -283,7 +282,7 @@ exports.childShouldThrowAndAbort = function() {
283
282
}
284
283
testCmd += `"${ process . argv [ 0 ] } " --abort-on-uncaught-exception ` ;
285
284
testCmd += `"${ process . argv [ 1 ] } " child` ;
286
- const child = child_process . exec ( testCmd ) ;
285
+ const child = exec ( testCmd ) ;
287
286
child . on ( 'exit' , function onExit ( exitCode , signal ) {
288
287
const errMsg = 'Test should have aborted ' +
289
288
`but instead exited with exit code ${ exitCode } ` +
@@ -303,8 +302,6 @@ exports.ddCommand = function(filename, kilobytes) {
303
302
304
303
305
304
exports . spawnPwd = function ( options ) {
306
- const spawn = require ( 'child_process' ) . spawn ;
307
-
308
305
if ( exports . isWindows ) {
309
306
return spawn ( 'cmd.exe' , [ '/d' , '/c' , 'cd' ] , options ) ;
310
307
} else {
@@ -314,8 +311,6 @@ exports.spawnPwd = function(options) {
314
311
315
312
316
313
exports . spawnSyncPwd = function ( options ) {
317
- const spawnSync = require ( 'child_process' ) . spawnSync ;
318
-
319
314
if ( exports . isWindows ) {
320
315
return spawnSync ( 'cmd.exe' , [ '/d' , '/c' , 'cd' ] , options ) ;
321
316
} else {
@@ -789,7 +784,7 @@ exports.getTTYfd = function getTTYfd() {
789
784
else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
790
785
else {
791
786
try {
792
- tty_fd = require ( 'fs' ) . openSync ( '/dev/tty' ) ;
787
+ tty_fd = fs . openSync ( '/dev/tty' ) ;
793
788
} catch ( e ) {
794
789
// There aren't any tty fd's available to use.
795
790
return - 1 ;
0 commit comments