UNPKG

electron-builder

Version:

A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box

85 lines (72 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NestedError = exports.executeFinally = undefined; var _bluebirdLstC; function _load_bluebirdLstC() { return _bluebirdLstC = require("bluebird-lst-c"); } var _bluebirdLstC2; function _load_bluebirdLstC2() { return _bluebirdLstC2 = _interopRequireDefault(require("bluebird-lst-c")); } // you don't need to handle error in your task - it is passed only indicate status of promise let executeFinally = exports.executeFinally = (() => { var _ref = (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* (promise, task) { let result = null; try { result = yield promise; } catch (originalError) { try { yield task(true); } catch (taskError) { throw new NestedError([originalError, taskError]); } throw originalError; } try { yield task(false); } catch (taskError) { throw taskError; } return result; }); return function executeFinally(_x, _x2) { return _ref.apply(this, arguments); }; })(); exports.printErrorAndExit = printErrorAndExit; exports.all = all; var _chalk; function _load_chalk() { return _chalk = require("chalk"); } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function printErrorAndExit(error) { console.error((0, (_chalk || _load_chalk()).red)((error.stack || error).toString())); process.exit(-1); }class NestedError extends Error { constructor(errors) { let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Compound error: "; let m = message; let i = 1; for (let error of errors) { const prefix = "Error #" + i++ + " "; m += "\n\n" + prefix + "-".repeat(80) + "\n" + error.stack; } super(m); } } exports.NestedError = NestedError; function all(promises) { const errors = []; return (_bluebirdLstC2 || _load_bluebirdLstC2()).default.all(promises.map(it => it.catch(it => errors.push(it)))).then(() => { if (errors.length === 1) { throw errors[0]; } else if (errors.length > 1) { throw new NestedError(errors, "Cannot cleanup: "); } }); } //# sourceMappingURL=promise.js.map