git ssb

4+

Dominic / scuttlebot



Commit 69dc20c646b477c874cb1f6eb145f9cd1016b04c

check name on both kinds of plugins

Henry committed on 12/17/2018, 11:57:50 AM
Parent: 36398834f84909b2c6a69f085596dd58efc6ca7b

Files changed

plugins/plugins.jschanged
plugins/plugins.jsView
@@ -184,25 +184,26 @@
184184 // iterate all modules
185185 var nodeModulesPath = path.join(config.path, 'node_modules')
186186 //instead of testing all plugins, only load things explicitly
187187 //enabled in the config
188- for(var module_name in config.plugins) {
188 + for (var module_name in config.plugins) {
189189 const configv = config.plugins[module_name]
190- if(configv) {
190 + if (configv) {
191191 const name = /^ssb-/.test(module_name) ? module_name.substring(4) : module_name
192192
193193 if (createSbot.plugins.some(plug => plug.name === name))
194194 throw new Error('already loaded plugin named:'+name)
195195
196196 let plugin = null
197- if (typeof configv === 'object') {
197 + if (typeof configv === 'object') { // out-of-process plugin
198198 plugin = require('ssb-plugins2/load')(configv.location)
199- plugin.name = name
200199 } else if (typeof configv === 'boolean') {
201200 plugin = require(path.join(nodeModulesPath, module_name))
202- if(!plugin || plugin.name !== name)
203- throw new Error('plugin at:'+module_name+' expected name:'+name+' but had:'+(plugin||{}).name)
204201 }
202 +
203 + if (!plugin || plugin.name !== name)
204 + throw new Error(`plugin at:${module_name} expected name:${name} but had:${(plugin||{}).name}`)
205 +
205206 assertSbotPlugin(plugin)
206207 createSbot.use(plugin)
207208 }
208209 }

Built with git-ssb-web