From 05e75c9a267cba9b408f59698a60a9b2e450de0d Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 2 Jun 2017 15:16:27 +0200 Subject: [PATCH] fix(Xo#registerPlugin): do not error if plugin not configured (#566) --- src/xo-mixins/plugins.js | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/xo-mixins/plugins.js b/src/xo-mixins/plugins.js index ce143e2af..4c158ffd7 100644 --- a/src/xo-mixins/plugins.js +++ b/src/xo-mixins/plugins.js @@ -90,23 +90,17 @@ export default class { }) } - // Configure plugin if necessary. (i.e. configurationSchema) - // Load plugin. - // Ignore configuration and loading errors. - Promise.resolve() - .then(() => { - if (!plugin.configured) { - return this._configurePlugin(plugin, configuration) - } - }) - .then(() => { - if (autoload) { - return this.loadPlugin(id) - } - }) - .catch(error => { - console.error('register plugin %s: %s', name, (error && error.stack) || error) - }) + if (configurationSchema !== undefined) { + if (configuration === undefined) { + return + } + + await this._configurePlugin(plugin, configuration) + } + + if (autoload) { + await this.loadPlugin(id) + } } async _getPlugin (id) {