Comparing version 1.0.0 to 1.0.1
@@ -176,10 +176,16 @@ var invariant = require('./invariant'); | ||
invariant(!!plugin.register ^ !!plugin.plugin, "Either 'plugin' or 'register' is required, cannot include both %s", hint); | ||
invariant( | ||
_.isFunction(plugin.register) || | ||
(plugin.plugin && _.isFunction(plugin.plugin.register)), | ||
"Plugin register must be a function or a required plugin module %s", hint); | ||
invariant(plugin.pluginName || plugin.name || (plugin.plugin && plugin.plugin.name), 'Plugin needs a name %s', hint); | ||
var register = plugin.register || plugin.plugin.register; | ||
var name = plugin.pluginName || plugin.name || plugin.plugin.name; | ||
var pluginOptions; | ||
var pluginMultiple; | ||
if (plugin.plugin) { | ||
pluginOptions = plugin.options; | ||
pluginMultiple = plugin.multiple; | ||
plugin = plugin.plugin; | ||
} | ||
invariant(_.isFunction(plugin.register), "Plugin register must be a function or a required plugin module %s", hint); | ||
invariant(plugin.pluginName || plugin.name, 'Plugin needs a name %s', hint); | ||
var register = plugin.register; | ||
var name = plugin.pluginName || plugin.name; | ||
@@ -191,4 +197,4 @@ invariant(name, "Missing plugin name %s", hint); | ||
name: name, | ||
multiple: plugin.multiple || false, | ||
options: plugin.options | ||
multiple: plugin.multiple || pluginMultiple || false, | ||
options: pluginOptions | ||
}; | ||
@@ -195,0 +201,0 @@ }); |
{ | ||
"name": "bly", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Flux app framework with hapi like interface", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -80,3 +80,3 @@ var test = require('tape'); | ||
test('App#register - passing options to plugin register function', function(t) { | ||
t.plan(2); | ||
t.plan(3); | ||
@@ -106,2 +106,13 @@ var app = new App(); | ||
}, "Can register with object containing plugin definition and options"); | ||
t.doesNotThrow(function() { | ||
var fnPlugin = function() {}; | ||
fnPlugin.register = emptyRegisterFn; | ||
fnPlugin.pluginName = 'acceptable-name'; | ||
app.register({ | ||
plugin: fnPlugin, | ||
options: pluginOptions | ||
}, emptyFn); | ||
}, "When passing a function plugin the pluginName prop is required"); | ||
}); | ||
@@ -108,0 +119,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51069
1063