Closed github-actions[bot] closed 4 years ago
test this, with preload, explicitly
https://github.com/senecajs/seneca/blob/6b4a5532f438a638cfdb69ac80e65ca8bc5d6b34/lib/use.js#L383
let plugin_done = spec.data.plugin_done; //return new Promise((resolve) => { var plugin_seneca = spec.data.delegate; var plugin_options = resolve_options(plugin.fullname, plugin, seneca); // Update stored plugin options (NOTE . != _ !!!) plugin.options = { ...plugin.options, ...plugin_options }; plugin.mark2 = Math.random(); // Update plugin options data in Seneca options. var seneca_options = { plugin: {} }; seneca_options.plugin[plugin.fullname] = plugin.options; seneca.options(seneca_options); plugin_seneca.log.debug({ kind: 'plugin', case: 'DEFINE', name: plugin.name, tag: plugin.tag, options: plugin_options, callpoint: spec.ctx.callpoint, }); var meta = define_plugin(plugin_seneca, plugin, seneca.util.clean(plugin_options)); plugin.meta = meta; // legacy api for service function if ('function' === typeof meta) { meta = { service: meta }; } // Plugin may have changed its own name dynamically plugin.name = meta.name || plugin.name; plugin.tag = meta.tag || plugin.tag || (plugin.options && plugin.options.tag$); plugin.fullname = Common.make_plugin_key(plugin); plugin.service = meta.service || plugin.service; plugin_seneca.__update_plugin__(plugin); seneca.private$.plugins[plugin.fullname] = plugin; seneca.private$.plugin_order.byname.push(plugin.name); seneca.private$.plugin_order.byname = Uniq(seneca.private$.plugin_order.byname); seneca.private$.plugin_order.byref.push(plugin.fullname); var exports = spec.data.exports; //console.log('EXPORTS', exports) //var exports = resolve_plugin_exports(plugin_seneca, plugin.fullname, meta) // 3.x Backwards compatibility - REMOVE in 4.x if ('amqp-transport' === plugin.name) { seneca.options({ legacy: { meta: true } }); } if ('function' === typeof plugin_options.defined$) { plugin_options.defined$(plugin); } // If init$ option false, do not execute init action. if (false === plugin_options.init$) { plugin_done(); //return resolve() } plugin_seneca.log.debug({ kind: 'plugin', case: 'INIT', name: plugin.name, tag: plugin.tag, exports: exports, }); plugin_seneca.act({ role: 'seneca', plugin: 'init', seq: spec.data.seq, init: plugin.name, tag: plugin.tag, default$: {}, fatal$: true, local$: true, }, function (err) { //try { if (err) { var plugin_err_code = 'plugin_init'; plugin.plugin_error = err.message; if (err.code === 'action-timeout') { plugin_err_code = 'plugin_init_timeout'; plugin.timeout = so.timeout; } return plugin_seneca.die( //internals.error(err, plugin_err_code, plugin) seneca.error(err, plugin_err_code, plugin)); } var fullname = plugin.name + (plugin.tag ? '$' + plugin.tag : ''); if (so.debug.print && so.debug.print.options) { Print.plugin_options(seneca, fullname, plugin_options); } plugin_seneca.log.info({ kind: 'plugin', case: 'READY', name: plugin.name, tag: plugin.tag, }); if ('function' === typeof plugin_options.inited$) { plugin_options.inited$(plugin); } plugin_done(); //return resolve() //} catch (e) { // console.log('QWE', e) // } }); // TODO: test this, with preload, explicitly return { op: 'merge', out: { meta, } }; }, }; }
Closed in 6d7a79515c7272184785478495f3958ed872c827
test this, with preload, explicitly
https://github.com/senecajs/seneca/blob/6b4a5532f438a638cfdb69ac80e65ca8bc5d6b34/lib/use.js#L383