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 <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]>
1 parent 2ce24a9 commit ea2d550

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

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
const MAX_BUFFER = 1024 * 1024;
5353

54-
exports.ChildProcess = ChildProcess;
55-
56-
exports.fork = function fork(modulePath /* , args, options */) {
54+
function fork(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
return spawn(options.execPath, args, options);
111-
};
112-
109+
}
113110

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

129125
function normalizeExecArgs(command, options, callback) {
130126
if (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) {
148144
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+
}
153149

154150
const customPromiseExecFunction = (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 = function execFile(file /* , args, options, callback */) {
171+
function execFile(file /* , args, options, callback */) {
176172
let args = [];
177173
let callback;
178174
let options;
@@ -386,11 +382,11 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
386382
child.addListener('error', errorhandler);
387383

388384
return child;
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
function 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) {
533529
const opts = normalizeSpawnArguments(file, args, options);
534530
const child = new ChildProcess();
535531

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

552548
return child;
553-
};
549+
}
554550

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

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

610605

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

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

648642

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

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

667660

668661
function validateTimeout(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)