From 4f05936d75da698ac7e1d27ce1f77d829021fde6 Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Wed, 9 Oct 2019 03:22:35 -0400 Subject: [PATCH] Add error catching in case the user doesn't have the config options set. --- pluginHandler.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pluginHandler.js b/pluginHandler.js index 2756ae87..2eb93294 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -21,11 +21,18 @@ module.exports.pluginHandler = function (parent) { obj.path = require('path'); obj.parent = parent; obj.pluginPath = obj.parent.path.join(obj.parent.datapath, 'plugins'); - obj.enabled = obj.parent.config.settings.plugins.enabled; - obj.loadList = obj.parent.config.settings.plugins.list; obj.plugins = {}; obj.exports = {}; + try { + obj.enabled = obj.parent.config.settings.plugins.enabled; + obj.loadList = obj.parent.config.settings.plugins.list; + } catch (e) { // Config file options not present, disable self + obj.enabled = false; + obj.loadList = {}; + console.log('Plugin options not added to the config file. Plugins disabled. Please see the documentation.'); + } + if (obj.enabled) { obj.loadList.forEach(function(plugin, index) { if (obj.fs.existsSync(obj.pluginPath + '/' + plugin)) {