mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
plugins: improve error handling and introduce getDecoratedConfig
This commit is contained in:
parent
0ca6faf544
commit
c2658ff1a0
1 changed files with 9 additions and 5 deletions
14
plugins.js
14
plugins.js
|
|
@ -233,7 +233,7 @@ function requirePlugins () {
|
|||
mod = require(path);
|
||||
|
||||
if (!mod || (!mod.onApp && !mod.onWindow && !mod.onUnload &&
|
||||
!mod.middleware &&
|
||||
!mod.middleware && !mod.reduceUI && !mod.reduceSessions &&
|
||||
!mod.decorateConfig && !mod.decorateMenu &&
|
||||
!mod.decorateTerm && !mod.decorateHyperTerm &&
|
||||
!mod.decorateTab && !mod.decorateNotification &&
|
||||
|
|
@ -243,6 +243,10 @@ function requirePlugins () {
|
|||
'HyperTerm extension API methods');
|
||||
return;
|
||||
}
|
||||
|
||||
// populate the name for internal errors here
|
||||
mod._name = basename(path);
|
||||
|
||||
return mod;
|
||||
} catch (err) {
|
||||
notify('Plugin error!', `Plugin "${basename(path)}" failed to load (${err.message})`);
|
||||
|
|
@ -285,15 +289,15 @@ exports.decorateMenu = function (tpl) {
|
|||
return decorated;
|
||||
};
|
||||
|
||||
exports.decorateConfig = function (config) {
|
||||
let decorated = config;
|
||||
exports.getDecoratedConfig = function () {
|
||||
let decorated = config.getConfig();
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.decorateConfig) {
|
||||
const res = plugin.decorateConfig(decorated);
|
||||
if (res) {
|
||||
if (res && 'object' === typeof res) {
|
||||
decorated = res;
|
||||
} else {
|
||||
console.error('incompatible response type for `decorateConfig`');
|
||||
notify('Plugin error!', `"${plugin._name}": invalid return type for \`decorateConfig\``);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue