forked from service-bot/pluginbot-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpluginbot-react.js
37 lines (28 loc) · 1.23 KB
/
pluginbot-react.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let Plugin = require("pluginbot/dist/plugin");
let PluginbotBase = require("pluginbot/dist/pluginbot-base");
class PluginbotClient {
/**
*
* @param configPath -- todo : put logic in case of non-webpack build...
*/
static async createPluginbot(configPath = null) {
if (configPath) {
throw "direct config Not supported yet - need webpack to prebuild.";
} else {
//assume webpack has built a config
let config = await require("pluginbot_client_config");
let plugins = {};
for (let [key, value] of Object.entries(config.plugins)) {
let pluginPackage = value.pluginPackage;
let pkgPart = pluginPackage.pluginbot.client;
let pluginName = key;
let pluginConfig = value.clientConfig;
//assumes the plugins have been generated already, realy dirty stuff here
let plugin = require("_plugins")[pluginName] || require("_plugins")["plugins/" + pluginName];
plugins[pluginName] = new Plugin(plugin, pluginPackage, pluginConfig, pkgPart);
}
return new PluginbotBase(plugins);
}
}
}
module.exports = PluginbotClient;