Add error catching in case the user doesn't have the config options set.
Ryan Blenis committed
Oct 9, 2019 at 03:22 UTC
e9d598264243cc8691c7d83dd78551ba0482636e
1 file changed
+9
-2
pluginHandler.js
+9
-2
@@ -21,11 +21,18 @@ module.exports.pluginHandler = function (parent) {
21
obj.path = require('path');
22
obj.parent = parent;
23
obj.pluginPath = obj.parent.path.join(obj.parent.datapath, 'plugins');
24
- obj.enabled = obj.parent.config.settings.plugins.enabled;
25
- obj.loadList = obj.parent.config.settings.plugins.list;
24
obj.plugins = {};
25
obj.exports = {};
26
27
+ try {
28
+ obj.enabled = obj.parent.config.settings.plugins.enabled;
29
+ obj.loadList = obj.parent.config.settings.plugins.list;
30
+ } catch (e) { // Config file options not present, disable self
31
+ obj.enabled = false;
32
+ obj.loadList = {};
33
+ console.log('Plugin options not added to the config file. Plugins disabled. Please see the documentation.');
34
+ }
35
+
36
if (obj.enabled) {
37
obj.loadList.forEach(function(plugin, index) {
38
if (obj.fs.existsSync(obj.pluginPath + '/' + plugin)) {