@@ -51,9 +51,7 @@ const {
51
51
52
52
const MAX_BUFFER = 1024 * 1024 ;
53
53
54
- exports . ChildProcess = ChildProcess ;
55
-
56
- exports . fork = function fork ( modulePath /* , args, options */ ) {
54
+ function fork ( modulePath /* , args, options */ ) {
57
55
validateString ( modulePath , 'modulePath' ) ;
58
56
59
57
// Get options and args arguments.
@@ -108,10 +106,9 @@ exports.fork = function fork(modulePath /* , args, options */) {
108
106
options . shell = false ;
109
107
110
108
return spawn ( options . execPath , args , options ) ;
111
- } ;
112
-
109
+ }
113
110
114
- exports . _forkChild = function _forkChild ( fd ) {
111
+ function _forkChild ( fd ) {
115
112
// set process.send()
116
113
const p = new Pipe ( PipeConstants . IPC ) ;
117
114
p . open ( fd ) ;
@@ -123,8 +120,7 @@ exports._forkChild = function _forkChild(fd) {
123
120
process . on ( 'removeListener' , function onRemoveListener ( name ) {
124
121
if ( name === 'message' || name === 'disconnect' ) control . unref ( ) ;
125
122
} ) ;
126
- } ;
127
-
123
+ }
128
124
129
125
function normalizeExecArgs ( command , options , callback ) {
130
126
if ( typeof options === 'function' ) {
@@ -144,12 +140,12 @@ function normalizeExecArgs(command, options, callback) {
144
140
}
145
141
146
142
147
- exports . exec = function exec ( command , options , callback ) {
143
+ function exec ( command , options , callback ) {
148
144
const 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
+ }
153
149
154
150
const customPromiseExecFunction = ( orig ) => {
155
151
return ( ...args ) => {
@@ -167,12 +163,12 @@ const customPromiseExecFunction = (orig) => {
167
163
} ;
168
164
} ;
169
165
170
- Object . defineProperty ( exports . exec , promisify . custom , {
166
+ Object . defineProperty ( exec , promisify . custom , {
171
167
enumerable : false ,
172
- value : customPromiseExecFunction ( exports . exec )
168
+ value : customPromiseExecFunction ( exec )
173
169
} ) ;
174
170
175
- exports . execFile = function execFile ( file /* , args, options, callback */ ) {
171
+ function execFile ( file /* , args, options, callback */ ) {
176
172
let args = [ ] ;
177
173
let callback ;
178
174
let options ;
@@ -386,11 +382,11 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
386
382
child . addListener ( 'error' , errorhandler ) ;
387
383
388
384
return child ;
389
- } ;
385
+ }
390
386
391
- Object . defineProperty ( exports . execFile , promisify . custom , {
387
+ Object . defineProperty ( execFile , promisify . custom , {
392
388
enumerable : false ,
393
- value : customPromiseExecFunction ( exports . execFile )
389
+ value : customPromiseExecFunction ( execFile )
394
390
} ) ;
395
391
396
392
function normalizeSpawnArguments ( file , args , options ) {
@@ -531,15 +527,15 @@ function normalizeSpawnArguments(file, args, options) {
531
527
}
532
528
533
529
534
- var spawn = exports . spawn = function spawn ( file , args , options ) {
530
+ function spawn ( file , args , options ) {
535
531
const child = new ChildProcess ( ) ;
536
532
537
533
options = normalizeSpawnArguments ( file , args , options ) ;
538
534
debug ( 'spawn' , options ) ;
539
535
child . spawn ( options ) ;
540
536
541
537
return child ;
542
- } ;
538
+ }
543
539
544
540
function spawnSync ( file , args , options ) {
545
541
options = {
@@ -587,7 +583,6 @@ function spawnSync(file, args, options) {
587
583
588
584
return child_process . spawnSync ( options ) ;
589
585
}
590
- exports . spawnSync = spawnSync ;
591
586
592
587
593
588
function checkExecSyncError ( ret , args , cmd ) {
@@ -625,7 +620,6 @@ function execFileSync(command, args, options) {
625
620
626
621
return ret . stdout ;
627
622
}
628
- exports . execFileSync = execFileSync ;
629
623
630
624
631
625
function execSync ( command , options ) {
@@ -644,7 +638,6 @@ function execSync(command, options) {
644
638
645
639
return ret . stdout ;
646
640
}
647
- exports . execSync = execSync ;
648
641
649
642
650
643
function validateTimeout ( timeout ) {
@@ -672,3 +665,15 @@ function sanitizeKillSignal(killSignal) {
672
665
killSignal ) ;
673
666
}
674
667
}
668
+
669
+ module . exports = {
670
+ _forkChild,
671
+ ChildProcess,
672
+ exec,
673
+ execFile,
674
+ execFileSync,
675
+ execSync,
676
+ fork,
677
+ spawn,
678
+ spawnSync
679
+ } ;
0 commit comments