summaryrefslogtreecommitdiff
path: root/lib/child_process.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/child_process.js')
-rw-r--r--lib/child_process.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index 5c315290c2..a790e85ee2 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -26,8 +26,6 @@ const {
deprecate, convertToValidSignal, getSystemErrorName
} = require('internal/util');
const { isUint8Array } = require('internal/util/types');
-const { createPromise,
- promiseResolve, promiseReject } = process.binding('util');
const debug = util.debuglog('child_process');
const { Buffer } = require('buffer');
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
@@ -152,18 +150,17 @@ exports.exec = function exec(command /* , options, callback */) {
const customPromiseExecFunction = (orig) => {
return (...args) => {
- const promise = createPromise();
-
- orig(...args, (err, stdout, stderr) => {
- if (err !== null) {
- err.stdout = stdout;
- err.stderr = stderr;
- promiseReject(promise, err);
- } else {
- promiseResolve(promise, { stdout, stderr });
- }
+ return new Promise((resolve, reject) => {
+ orig(...args, (err, stdout, stderr) => {
+ if (err !== null) {
+ err.stdout = stdout;
+ err.stderr = stderr;
+ reject(err);
+ } else {
+ resolve({ stdout, stderr });
+ }
+ });
});
- return promise;
};
};