Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

complete callback handling in use()

  • Loading branch information...
commit 69a47e7d7673ae9944fc0f0666265e23813c86f4 1 parent 41328d0
@rvagg rvagg authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/broadway/app.js
View
12 lib/broadway/app.js
@@ -136,10 +136,7 @@ App.prototype.use = function (plugin, options, callback) {
if (typeof plugin === 'undefined') {
console.log('Cannot load invalid plugin!');
- if (callback) {
- callback(new Error('Invalid plugin'));
- }
- return;
+ return callback && callback(new Error('Invalid plugin'));
}
var name = plugin.name,
@@ -173,12 +170,13 @@ App.prototype.use = function (plugin, options, callback) {
// not false. This allows for some plugins to be lazy-loaded
//
if (options.init === false) {
- return;
+ return callback && callback();
}
if (!this.initialized) {
this.initializers[name] = plugin.init || true;
this.initlist.push(name);
+ return callback && callback();
}
else if (plugin.init) {
plugin.init.call(this, function (err) {
@@ -187,9 +185,7 @@ App.prototype.use = function (plugin, options, callback) {
: [['plugin', name, 'init']];
self.emit.apply(self, args);
- if (callback) {
- return err ? callback(err) : callback();
- }
+ return callback && (err ? callback(err) : callback());
});
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.