@@ -51,9 +51,7 @@ const {
5151
5252const MAX_BUFFER = 1024 * 1024 ;
5353
54- exports . ChildProcess = ChildProcess ;
55-
56- exports . fork = function fork ( modulePath /* , args, options */ ) {
54+ function fork ( modulePath /* , args, options */ ) {
5755validateString ( modulePath , 'modulePath' ) ;
5856
5957// Get options and args arguments.
@@ -108,10 +106,9 @@ exports.fork = function fork(modulePath /* , args, options */) {
108106options . shell = false ;
109107
110108return spawn ( options . execPath , args , options ) ;
111- } ;
112-
109+ }
113110
114- exports . _forkChild = function _forkChild ( fd ) {
111+ function _forkChild ( fd ) {
115112// set process.send()
116113const p = new Pipe ( PipeConstants . IPC ) ;
117114p . open ( fd ) ;
@@ -123,8 +120,7 @@ exports._forkChild = function _forkChild(fd) {
123120process . on ( 'removeListener' , function onRemoveListener ( name ) {
124121if ( name === 'message' || name === 'disconnect' ) control . unref ( ) ;
125122} ) ;
126- } ;
127-
123+ }
128124
129125function normalizeExecArgs ( command , options , callback ) {
130126if ( typeof options === 'function' ) {
@@ -144,12 +140,12 @@ function normalizeExecArgs(command, options, callback) {
144140}
145141
146142
147- exports . exec = function exec ( command , options , callback ) {
143+ function exec ( command , options , callback ) {
148144const opts = normalizeExecArgs ( command , options , callback ) ;
149- return exports . execFile ( opts . file ,
150- opts . options ,
151- opts . callback ) ;
152- } ;
145+ return module . exports . execFile ( opts . file ,
146+ opts . options ,
147+ opts . callback ) ;
148+ }
153149
154150const customPromiseExecFunction = ( orig ) => {
155151return ( ...args ) => {
@@ -167,12 +163,12 @@ const customPromiseExecFunction = (orig) => {
167163} ;
168164} ;
169165
170- Object . defineProperty ( exports . exec , promisify . custom , {
166+ Object . defineProperty ( exec , promisify . custom , {
171167enumerable : false ,
172- value : customPromiseExecFunction ( exports . exec )
168+ value : customPromiseExecFunction ( exec )
173169} ) ;
174170
175- exports . execFile = function execFile ( file /* , args, options, callback */ ) {
171+ function execFile ( file /* , args, options, callback */ ) {
176172let args = [ ] ;
177173let callback ;
178174let options ;
@@ -386,11 +382,11 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
386382child . addListener ( 'error' , errorhandler ) ;
387383
388384return child ;
389- } ;
385+ }
390386
391- Object . defineProperty ( exports . execFile , promisify . custom , {
387+ Object . defineProperty ( execFile , promisify . custom , {
392388enumerable : false ,
393- value : customPromiseExecFunction ( exports . execFile )
389+ value : customPromiseExecFunction ( execFile )
394390} ) ;
395391
396392function normalizeSpawnArguments ( file , args , options ) {
@@ -529,7 +525,7 @@ function normalizeSpawnArguments(file, args, options) {
529525}
530526
531527
532- var spawn = exports . spawn = function spawn ( file , args , options ) {
528+ function spawn ( file , args , options ) {
533529const opts = normalizeSpawnArguments ( file , args , options ) ;
534530const child = new ChildProcess ( ) ;
535531
@@ -550,7 +546,7 @@ var spawn = exports.spawn = function spawn(file, args, options) {
550546} ) ;
551547
552548return child ;
553- } ;
549+ }
554550
555551function spawnSync ( file , args , options ) {
556552const opts = normalizeSpawnArguments ( file , args , options ) ;
@@ -605,7 +601,6 @@ function spawnSync(file, args, options) {
605601
606602return child_process . spawnSync ( opts ) ;
607603}
608- exports . spawnSync = spawnSync ;
609604
610605
611606function checkExecSyncError ( ret , args , cmd ) {
@@ -643,7 +638,6 @@ function execFileSync(command, args, options) {
643638
644639return ret . stdout ;
645640}
646- exports . execFileSync = execFileSync ;
647641
648642
649643function execSync ( command , options ) {
@@ -662,7 +656,6 @@ function execSync(command, options) {
662656
663657return ret . stdout ;
664658}
665- exports . execSync = execSync ;
666659
667660
668661function validateTimeout ( timeout ) {
@@ -690,3 +683,15 @@ function sanitizeKillSignal(killSignal) {
690683killSignal ) ;
691684}
692685}
686+
687+ module . exports = {
688+ _forkChild,
689+ ChildProcess,
690+ exec,
691+ execFile,
692+ execFileSync,
693+ execSync,
694+ fork,
695+ spawn,
696+ spawnSync
697+ } ;
0 commit comments