@@ -25,11 +25,10 @@ const path = require('path');
2525const fs = require ( 'fs' ) ;
2626const assert = require ( 'assert' ) ;
2727const os = require ( 'os' ) ;
28- const child_process = require ( 'child_process' ) ;
28+ const { exec , execSync , spawn , spawnSync } = require ( 'child_process' ) ;
2929const stream = require ( 'stream' ) ;
3030const util = require ( 'util' ) ;
3131const Timer = process . binding ( 'timer_wrap' ) . Timer ;
32- const execSync = require ( 'child_process' ) . execSync ;
3332
3433const testRoot = process . env . NODE_TEST_DIR ?
3534 fs . realpathSync ( process . env . NODE_TEST_DIR ) : path . resolve ( __dirname , '..' ) ;
@@ -186,7 +185,7 @@ Object.defineProperty(exports, 'inFreeBSDJail', {
186185 if ( inFreeBSDJail !== null ) return inFreeBSDJail ;
187186
188187 if ( exports . isFreeBSD &&
189- child_process . execSync ( 'sysctl -n security.jail.jailed' ) . toString ( ) ===
188+ execSync ( 'sysctl -n security.jail.jailed' ) . toString ( ) ===
190189 '1\n' ) {
191190 inFreeBSDJail = true ;
192191 } else {
@@ -233,7 +232,7 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
233232
234233 if ( exports . isWindows ) opensslCli += '.exe' ;
235234
236- const opensslCmd = child_process . spawnSync ( opensslCli , [ 'version' ] ) ;
235+ const opensslCmd = spawnSync ( opensslCli , [ 'version' ] ) ;
237236 if ( opensslCmd . status !== 0 || opensslCmd . error !== undefined ) {
238237 // openssl command cannot be executed
239238 opensslCli = false ;
@@ -283,7 +282,7 @@ exports.childShouldThrowAndAbort = function() {
283282 }
284283 testCmd += `"${ process . argv [ 0 ] } " --abort-on-uncaught-exception ` ;
285284 testCmd += `"${ process . argv [ 1 ] } " child` ;
286- const child = child_process . exec ( testCmd ) ;
285+ const child = exec ( testCmd ) ;
287286 child . on ( 'exit' , function onExit ( exitCode , signal ) {
288287 const errMsg = 'Test should have aborted ' +
289288 `but instead exited with exit code ${ exitCode } ` +
@@ -303,8 +302,6 @@ exports.ddCommand = function(filename, kilobytes) {
303302
304303
305304exports . spawnPwd = function ( options ) {
306- const spawn = require ( 'child_process' ) . spawn ;
307-
308305 if ( exports . isWindows ) {
309306 return spawn ( 'cmd.exe' , [ '/d' , '/c' , 'cd' ] , options ) ;
310307 } else {
@@ -314,8 +311,6 @@ exports.spawnPwd = function(options) {
314311
315312
316313exports . spawnSyncPwd = function ( options ) {
317- const spawnSync = require ( 'child_process' ) . spawnSync ;
318-
319314 if ( exports . isWindows ) {
320315 return spawnSync ( 'cmd.exe' , [ '/d' , '/c' , 'cd' ] , options ) ;
321316 } else {
@@ -789,7 +784,7 @@ exports.getTTYfd = function getTTYfd() {
789784 else if ( ! tty . isatty ( tty_fd ) ) tty_fd ++ ;
790785 else {
791786 try {
792- tty_fd = require ( 'fs' ) . openSync ( '/dev/tty' ) ;
787+ tty_fd = fs . openSync ( '/dev/tty' ) ;
793788 } catch ( e ) {
794789 // There aren't any tty fd's available to use.
795790 return - 1 ;
0 commit comments