Comparing version 7.1.2 to 7.2.0
@@ -194,5 +194,11 @@ 'use strict' | ||
function assertPlugin (plugin) { | ||
// Faux modules are modules built with TypeScript | ||
// or Babel that they export a .default property. | ||
if (plugin && typeof plugin === 'object' && typeof plugin.default === 'function') { | ||
plugin = plugin.default | ||
} | ||
if (!(plugin && (typeof plugin === 'function' || typeof plugin.then === 'function'))) { | ||
throw new Error('plugin must be a function or a promise') | ||
} | ||
return plugin | ||
} | ||
@@ -228,3 +234,3 @@ | ||
Boot.prototype._addPlugin = function (plugin, opts, isAfter) { | ||
assertPlugin(plugin) | ||
plugin = assertPlugin(plugin) | ||
opts = opts || {} | ||
@@ -231,0 +237,0 @@ |
{ | ||
"name": "avvio", | ||
"version": "7.1.2", | ||
"version": "7.2.0", | ||
"description": "Asynchronous bootstrapping of Node applications", | ||
@@ -5,0 +5,0 @@ "main": "boot.js", |
@@ -375,1 +375,25 @@ 'use strict' | ||
}) | ||
test('support faux modules', (t) => { | ||
t.plan(4) | ||
const app = boot() | ||
var after = false | ||
// Faux modules are modules built with TypeScript | ||
// or Babel that they export a .default property. | ||
app.use({ | ||
default: function (server, opts, done) { | ||
t.equal(server, app, 'the first argument is the server') | ||
t.deepEqual(opts, {}, 'no options') | ||
t.ok(after, 'delayed execution') | ||
done() | ||
} | ||
}) | ||
after = true | ||
app.on('start', () => { | ||
t.pass('booted') | ||
}) | ||
}) |
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
135022
4590