UNPKG

@easy-breezy/core

Version:
40 lines (39 loc) 1.48 kB
import args from './../args/index.js'; import i18n from './../i18n/index.js'; import config from './../config/index.js'; import fs from './../fs/index.js'; import colors from './../colors/index.js'; import output from './../output/index.js'; class Plugin { run = async () => { const plugins = config.get('plugins'); if (plugins) { const keys = Object.keys(plugins); if (keys.length) { for (const key of keys) { const { default: module } = await import(`@easy-breezy/plugin-${key}`); try { await module({ i18n: { addResource: (lang, payload) => i18n.addResource(lang, key, payload), t: i18n.bindT(key) }, config: { get: config.bindGet(`plugins.${key}`), set: config.bindSet(`plugins.${key}`) }, output: output.bind(`plugins.${key}`), colors, fs, args }); } catch (error) { output.error(`[plugin-${key}]: ${error}`); } } } } }; } export default new Plugin();