git ssb

4+

Dominic / scuttlebot



Commit 66ea5fb7f20bcb120716849b8b81dd19854a758b

Improve robustness of loading user-plugins

- Skip loading a plugin with an already-used name,
  as mentioned in https://github.com/ssbc/scuttlebot/pull/407#issuecomment-305742813
- Add back plugin loading error checking removed in 5653a26d6cfcd9a9cff414d2c291fc24e7a294aa
cel committed on 6/2/2017, 8:51:48 PM
Parent: b10a374c7cfd761f03556b17d9957ff5853da2fd

Files changed

plugins/plugins.jschanged
plugins/plugins.jsView
@@ -174,10 +174,19 @@
174174 var nodeModulesPath = path.join(config.path, 'node_modules')
175175 //instead of testing all plugins, only load things explicitly
176176 //enabled in the config
177177 for(var k in config.plugins) {
178- if(config.plugins[k])
179- createSbot.use(require(path.join(nodeModulesPath, k)))
178+ if(config.plugins[k]) {
179+ try {
180+ var plugin = require(path.join(nodeModulesPath, k))
181+ assertSbotPlugin(plugin)
182+ if (createSbot.plugins.some(plug => plug.name === plugin.name))
183+ throw new Error('already loaded')
184+ createSbot.use(plugin)
185+ } catch (e) {
186+ console.error('Error loading plugin "'+k+'":', e.message)
187+ }
188+ }
180189 }
181190 }
182191
183192 // predictate to check if an object appears to be a sbot plugin

Built with git-ssb-web