Skip to content

Commit aa00968

Browse files
himself65Trott
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 cb92d24 commit aa00968

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

Diff for: lib/child_process.js

+29-24
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) {
@@ -531,15 +527,15 @@ function normalizeSpawnArguments(file, args, options) {
531527
}
532528

533529

534-
var spawn = exports.spawn = function spawn(file, args, options) {
530+
function spawn(file, args, options) {
535531
const child = new ChildProcess();
536532

537533
options = normalizeSpawnArguments(file, args, options);
538534
debug('spawn', options);
539535
child.spawn(options);
540536

541537
return child;
542-
};
538+
}
543539

544540
function spawnSync(file, args, options) {
545541
options = {
@@ -587,7 +583,6 @@ function spawnSync(file, args, options) {
587583

588584
return child_process.spawnSync(options);
589585
}
590-
exports.spawnSync = spawnSync;
591586

592587

593588
function checkExecSyncError(ret, args, cmd) {
@@ -625,7 +620,6 @@ function execFileSync(command, args, options) {
625620

626621
return ret.stdout;
627622
}
628-
exports.execFileSync = execFileSync;
629623

630624

631625
function execSync(command, options) {
@@ -644,7 +638,6 @@ function execSync(command, options) {
644638

645639
return ret.stdout;
646640
}
647-
exports.execSync = execSync;
648641

649642

650643
function validateTimeout(timeout) {
@@ -672,3 +665,15 @@ function sanitizeKillSignal(killSignal) {
672665
killSignal);
673666
}
674667
}
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

Comments
 (0)