Skip to content

Commit ea2d550

Browse files
himself65targos
authored andcommitted
child_process: move exports to bottom for consistent code style
PR-URL: #27845 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
1 parent 2ce24a9 commit ea2d550

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

‎lib/child_process.js‎

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ const {
5151

5252
constMAX_BUFFER=1024*1024;
5353

54-
exports.ChildProcess=ChildProcess;
55-
56-
exports.fork=functionfork(modulePath/* , args, options */){
54+
functionfork(modulePath/* , args, options */){
5755
validateString(modulePath,'modulePath');
5856

5957
// Get options and args arguments.
@@ -108,10 +106,9 @@ exports.fork = function fork(modulePath /* , args, options */) {
108106
options.shell=false;
109107

110108
returnspawn(options.execPath,args,options);
111-
};
112-
109+
}
113110

114-
exports._forkChild=function_forkChild(fd){
111+
function_forkChild(fd){
115112
// set process.send()
116113
constp=newPipe(PipeConstants.IPC);
117114
p.open(fd);
@@ -123,8 +120,7 @@ exports._forkChild = function _forkChild(fd) {
123120
process.on('removeListener',functiononRemoveListener(name){
124121
if(name==='message'||name==='disconnect')control.unref();
125122
});
126-
};
127-
123+
}
128124

129125
functionnormalizeExecArgs(command,options,callback){
130126
if(typeofoptions==='function'){
@@ -144,12 +140,12 @@ function normalizeExecArgs(command, options, callback) {
144140
}
145141

146142

147-
exports.exec=functionexec(command,options,callback){
143+
functionexec(command,options,callback){
148144
constopts=normalizeExecArgs(command,options,callback);
149-
returnexports.execFile(opts.file,
150-
opts.options,
151-
opts.callback);
152-
};
145+
returnmodule.exports.execFile(opts.file,
146+
opts.options,
147+
opts.callback);
148+
}
153149

154150
constcustomPromiseExecFunction=(orig)=>{
155151
return(...args)=>{
@@ -167,12 +163,12 @@ const customPromiseExecFunction = (orig) => {
167163
};
168164
};
169165

170-
Object.defineProperty(exports.exec,promisify.custom,{
166+
Object.defineProperty(exec,promisify.custom,{
171167
enumerable: false,
172-
value: customPromiseExecFunction(exports.exec)
168+
value: customPromiseExecFunction(exec)
173169
});
174170

175-
exports.execFile=functionexecFile(file/* , args, options, callback */){
171+
functionexecFile(file/* , args, options, callback */){
176172
letargs=[];
177173
letcallback;
178174
letoptions;
@@ -386,11 +382,11 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
386382
child.addListener('error',errorhandler);
387383

388384
returnchild;
389-
};
385+
}
390386

391-
Object.defineProperty(exports.execFile,promisify.custom,{
387+
Object.defineProperty(execFile,promisify.custom,{
392388
enumerable: false,
393-
value: customPromiseExecFunction(exports.execFile)
389+
value: customPromiseExecFunction(execFile)
394390
});
395391

396392
functionnormalizeSpawnArguments(file,args,options){
@@ -529,7 +525,7 @@ function normalizeSpawnArguments(file, args, options) {
529525
}
530526

531527

532-
varspawn=exports.spawn=functionspawn(file,args,options){
528+
functionspawn(file,args,options){
533529
constopts=normalizeSpawnArguments(file,args,options);
534530
constchild=newChildProcess();
535531

@@ -550,7 +546,7 @@ var spawn = exports.spawn = function spawn(file, args, options) {
550546
});
551547

552548
returnchild;
553-
};
549+
}
554550

555551
functionspawnSync(file,args,options){
556552
constopts=normalizeSpawnArguments(file,args,options);
@@ -605,7 +601,6 @@ function spawnSync(file, args, options) {
605601

606602
returnchild_process.spawnSync(opts);
607603
}
608-
exports.spawnSync=spawnSync;
609604

610605

611606
functioncheckExecSyncError(ret,args,cmd){
@@ -643,7 +638,6 @@ function execFileSync(command, args, options) {
643638

644639
returnret.stdout;
645640
}
646-
exports.execFileSync=execFileSync;
647641

648642

649643
functionexecSync(command,options){
@@ -662,7 +656,6 @@ function execSync(command, options) {
662656

663657
returnret.stdout;
664658
}
665-
exports.execSync=execSync;
666659

667660

668661
functionvalidateTimeout(timeout){
@@ -690,3 +683,15 @@ function sanitizeKillSignal(killSignal) {
690683
killSignal);
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

Comments
 (0)