Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
node 8 changed from util.createPromise to new Promise as well
Browse files Browse the repository at this point in the history
  • Loading branch information
igorklopov committed May 11, 2019
1 parent ee56bd7 commit 3952f39
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1459,32 +1459,14 @@ function payloadFileSync (pointer) {
if (promisify) {
var custom = promisify.custom;
var customPromisifyArgs = require('internal/util').customPromisifyArgs;
var createPromise;

if (NODE_VERSION_MAJOR <= 8) {
var binding = process.binding('util');
var promiseResolve = binding.promiseResolve;
var promiseReject = binding.promiseReject;
createPromise = function (fn) {
var p = binding.createPromise;
var resolve = promiseResolve.bind(p);
var reject = promiseReject.bind(p);
fn(resolve, reject);
return p;
};
} else {
createPromise = function (fn) {
return new Promise(fn);
};
}

// /////////////////////////////////////////////////////////////
// FS //////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////

Object.defineProperty(require('fs').exists, custom, {
value: function (path) {
return createPromise(function (resolve) {
return new Promise(function (resolve) {
require('fs').exists(path, function (exists) {
resolve(exists);
});
Expand All @@ -1507,7 +1489,7 @@ function payloadFileSync (pointer) {
var customPromiseExecFunction = function (o) {
return function () {
var args = Array.from(arguments);
return createPromise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
o.apply(undefined, args.concat(function (error, stdout, stderr) {
if (error !== null) {
error.stdout = stdout;
Expand Down

0 comments on commit 3952f39

Please sign in to comment.