summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhimself65 <himself65@outlook.com>2019-05-29 22:03:45 +0800
committerRich Trott <rtrott@gmail.com>2019-06-02 15:32:01 +0200
commitaa00968255cdb6471b9e7fec99337697a2ce882c (patch)
tree56e6c97bb4f7f4749c6ebcc44feac02bcc571cbd /lib
parentcb92d243e8b3603cf4abd231abe83179950927fc (diff)
downloadandroid-node-v8-aa00968255cdb6471b9e7fec99337697a2ce882c.tar.gz
android-node-v8-aa00968255cdb6471b9e7fec99337697a2ce882c.tar.bz2
android-node-v8-aa00968255cdb6471b9e7fec99337697a2ce882c.zip
child_process: move exports to bottom for consistent code style
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib')
-rw-r--r--lib/child_process.js53
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index d5037d96fc..623c852d1e 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -51,9 +51,7 @@ const {
const MAX_BUFFER = 1024 * 1024;
-exports.ChildProcess = ChildProcess;
-
-exports.fork = function fork(modulePath /* , args, options */) {
+function fork(modulePath /* , args, options */) {
validateString(modulePath, 'modulePath');
// Get options and args arguments.
@@ -108,10 +106,9 @@ exports.fork = function fork(modulePath /* , args, options */) {
options.shell = false;
return spawn(options.execPath, args, options);
-};
-
+}
-exports._forkChild = function _forkChild(fd) {
+function _forkChild(fd) {
// set process.send()
const p = new Pipe(PipeConstants.IPC);
p.open(fd);
@@ -123,8 +120,7 @@ exports._forkChild = function _forkChild(fd) {
process.on('removeListener', function onRemoveListener(name) {
if (name === 'message' || name === 'disconnect') control.unref();
});
-};
-
+}
function normalizeExecArgs(command, options, callback) {
if (typeof options === 'function') {
@@ -144,12 +140,12 @@ function normalizeExecArgs(command, options, callback) {
}
-exports.exec = function exec(command, options, callback) {
+function exec(command, options, callback) {
const opts = normalizeExecArgs(command, options, callback);
- return exports.execFile(opts.file,
- opts.options,
- opts.callback);
-};
+ return module.exports.execFile(opts.file,
+ opts.options,
+ opts.callback);
+}
const customPromiseExecFunction = (orig) => {
return (...args) => {
@@ -167,12 +163,12 @@ const customPromiseExecFunction = (orig) => {
};
};
-Object.defineProperty(exports.exec, promisify.custom, {
+Object.defineProperty(exec, promisify.custom, {
enumerable: false,
- value: customPromiseExecFunction(exports.exec)
+ value: customPromiseExecFunction(exec)
});
-exports.execFile = function execFile(file /* , args, options, callback */) {
+function execFile(file /* , args, options, callback */) {
let args = [];
let callback;
let options;
@@ -386,11 +382,11 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
child.addListener('error', errorhandler);
return child;
-};
+}
-Object.defineProperty(exports.execFile, promisify.custom, {
+Object.defineProperty(execFile, promisify.custom, {
enumerable: false,
- value: customPromiseExecFunction(exports.execFile)
+ value: customPromiseExecFunction(execFile)
});
function normalizeSpawnArguments(file, args, options) {
@@ -531,7 +527,7 @@ function normalizeSpawnArguments(file, args, options) {
}
-var spawn = exports.spawn = function spawn(file, args, options) {
+function spawn(file, args, options) {
const child = new ChildProcess();
options = normalizeSpawnArguments(file, args, options);
@@ -539,7 +535,7 @@ var spawn = exports.spawn = function spawn(file, args, options) {
child.spawn(options);
return child;
-};
+}
function spawnSync(file, args, options) {
options = {
@@ -587,7 +583,6 @@ function spawnSync(file, args, options) {
return child_process.spawnSync(options);
}
-exports.spawnSync = spawnSync;
function checkExecSyncError(ret, args, cmd) {
@@ -625,7 +620,6 @@ function execFileSync(command, args, options) {
return ret.stdout;
}
-exports.execFileSync = execFileSync;
function execSync(command, options) {
@@ -644,7 +638,6 @@ function execSync(command, options) {
return ret.stdout;
}
-exports.execSync = execSync;
function validateTimeout(timeout) {
@@ -672,3 +665,15 @@ function sanitizeKillSignal(killSignal) {
killSignal);
}
}
+
+module.exports = {
+ _forkChild,
+ ChildProcess,
+ exec,
+ execFile,
+ execFileSync,
+ execSync,
+ fork,
+ spawn,
+ spawnSync
+};