fix(xo-server/plugins): try empty config if none provided (#4647)
Required by #4581 Plugins with optional configuration should be loadable without explicit user configuration.
This commit is contained in:
@@ -60,7 +60,7 @@ export default class {
|
||||
const plugin = (this._plugins[id] = {
|
||||
configurationPresets,
|
||||
configurationSchema,
|
||||
configured: !configurationSchema,
|
||||
configured: configurationSchema === undefined,
|
||||
description,
|
||||
id,
|
||||
instance,
|
||||
@@ -84,12 +84,17 @@ export default class {
|
||||
})
|
||||
}
|
||||
|
||||
if (configurationSchema !== undefined) {
|
||||
if (configuration === undefined) {
|
||||
return
|
||||
if (!plugin.configured) {
|
||||
const tryEmptyConfig = configuration === undefined
|
||||
try {
|
||||
await this._configurePlugin(plugin, tryEmptyConfig ? {} : configuration)
|
||||
} catch (error) {
|
||||
// dont throw any error in case the empty config did not work
|
||||
if (tryEmptyConfig) {
|
||||
return
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
await this._configurePlugin(plugin, configuration)
|
||||
}
|
||||
|
||||
if (autoload) {
|
||||
|
||||
Reference in New Issue
Block a user