2019-06-03 09:47:07 +00:00
|
|
|
"use strict";
|
2019-06-03 09:34:52 +00:00
|
|
|
|
|
|
|
function requireBluebird() {
|
2019-11-01 21:14:07 +00:00
|
|
|
try {
|
|
|
|
return require("bluebird");
|
|
|
|
} catch (e) {
|
|
|
|
console.error("");
|
|
|
|
console.error("DON'T PANIC. You're running an old version of node with incomplete Promise support.");
|
|
|
|
console.error("EASY FIX: `npm install --save bluebird`");
|
|
|
|
console.error("");
|
|
|
|
throw e;
|
|
|
|
}
|
2019-06-03 09:34:52 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 09:47:07 +00:00
|
|
|
if ("undefined" === typeof Promise) {
|
2019-11-01 21:14:07 +00:00
|
|
|
global.Promise = requireBluebird();
|
2019-06-03 09:34:52 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 09:47:07 +00:00
|
|
|
if ("function" !== typeof require("util").promisify) {
|
2019-11-01 21:14:07 +00:00
|
|
|
require("util").promisify = requireBluebird().promisify;
|
2019-06-03 09:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!console.debug) {
|
2019-11-01 21:14:07 +00:00
|
|
|
console.debug = console.log;
|
2019-06-03 09:34:52 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 09:47:07 +00:00
|
|
|
var fs = require("fs");
|
2019-06-03 09:34:52 +00:00
|
|
|
var fsAsync = {};
|
2019-06-03 09:47:07 +00:00
|
|
|
Object.keys(fs).forEach(function(key) {
|
2019-11-01 21:14:07 +00:00
|
|
|
var fn = fs[key];
|
|
|
|
if ("function" !== typeof fn || !/[a-z]/.test(key[0])) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fsAsync[key] = require("util").promisify(fn);
|
2019-06-03 09:34:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
exports.fsAsync = fsAsync;
|