fs: promisify exists correctly · nodejs/node@6e0eccd
@@ -28,7 +28,7 @@ const constants = process.binding('constants').fs;
2828const { S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK } = constants;
2929const util = require('util');
3030const pathModule = require('path');
31-const { isUint8Array } = process.binding('util');
31+const { isUint8Array, createPromise, promiseResolve } = process.binding('util');
32323333const binding = process.binding('fs');
3434const fs = exports;
@@ -308,6 +308,15 @@ fs.exists = function(path, callback) {
308308}
309309};
310310311+Object.defineProperty(fs.exists, internalUtil.promisify.custom, {
312+value: (path) => {
313+const promise = createPromise();
314+fs.exists(path, (exists) => promiseResolve(promise, exists));
315+return promise;
316+}
317+});
318+319+311320fs.existsSync = function(path) {
312321try {
313322handleError((path = getPathFromURL(path)));