UNPKG

@omni-door/cli

Version:

A tool set for set up the standard JS project

24 lines (23 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handlerFactory = exports.getHandlers = void 0; var utils_1 = require("@omni-door/utils"); function getHandlers(plugins, stage) { var handlers = {}; for (var i = 0; i < plugins.length; i++) { var plugin = plugins[i]; plugin.stage === stage && (handlers[plugin.name] = exports.handlerFactory(plugin.handler, "The \"" + plugin.name + "\" execution error, will skip to continue the rest of the operaions(\u63D2\u4EF6 \"" + plugin.name + "\" \u6267\u884C\u53D1\u751F\u9519\u8BEF\uFF0C\u5C06\u8DF3\u8FC7\u7EE7\u7EED\u6267\u884C\u5269\u4F59\u64CD\u4F5C)")); } return handlers; } exports.getHandlers = getHandlers; exports.handlerFactory = function (handler, errMsg) { return function (config, options) { try { return Promise.resolve(handler(config, options)); } catch (err) { utils_1.logWarn(err); utils_1.logWarn(errMsg || 'The plugin execution error, will skip to continue the rest of the operaions(插件执行发生错误,将跳过继续执行剩余操作)'); } return Promise.resolve({}); }; };