mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28: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);
|
mod = require(path);
|
||||||
|
|
||||||
if (!mod || (!mod.onApp && !mod.onWindow && !mod.onUnload &&
|
if (!mod || (!mod.onApp && !mod.onWindow && !mod.onUnload &&
|
||||||
!mod.middleware &&
|
!mod.middleware && !mod.reduceUI && !mod.reduceSessions &&
|
||||||
!mod.decorateConfig && !mod.decorateMenu &&
|
!mod.decorateConfig && !mod.decorateMenu &&
|
||||||
!mod.decorateTerm && !mod.decorateHyperTerm &&
|
!mod.decorateTerm && !mod.decorateHyperTerm &&
|
||||||
!mod.decorateTab && !mod.decorateNotification &&
|
!mod.decorateTab && !mod.decorateNotification &&
|
||||||
|
|
@ -243,6 +243,10 @@ function requirePlugins () {
|
||||||
'HyperTerm extension API methods');
|
'HyperTerm extension API methods');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// populate the name for internal errors here
|
||||||
|
mod._name = basename(path);
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notify('Plugin error!', `Plugin "${basename(path)}" failed to load (${err.message})`);
|
notify('Plugin error!', `Plugin "${basename(path)}" failed to load (${err.message})`);
|
||||||
|
|
@ -285,15 +289,15 @@ exports.decorateMenu = function (tpl) {
|
||||||
return decorated;
|
return decorated;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.decorateConfig = function (config) {
|
exports.getDecoratedConfig = function () {
|
||||||
let decorated = config;
|
let decorated = config.getConfig();
|
||||||
modules.forEach((plugin) => {
|
modules.forEach((plugin) => {
|
||||||
if (plugin.decorateConfig) {
|
if (plugin.decorateConfig) {
|
||||||
const res = plugin.decorateConfig(decorated);
|
const res = plugin.decorateConfig(decorated);
|
||||||
if (res) {
|
if (res && 'object' === typeof res) {
|
||||||
decorated = res;
|
decorated = res;
|
||||||
} else {
|
} else {
|
||||||
console.error('incompatible response type for `decorateConfig`');
|
notify('Plugin error!', `"${plugin._name}": invalid return type for \`decorateConfig\``);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue