fix missing callback

v1.18.x
barisusakli 9 years ago
parent 1f5d3a92d6
commit 11236bb841

@ -14,17 +14,17 @@ module.exports = function(Plugins) {
`data.priority`, the relative priority of the method when it is eventually called (default: 10) `data.priority`, the relative priority of the method when it is eventually called (default: 10)
*/ */
Plugins.registerHook = function(id, data, callback) { Plugins.registerHook = function(id, data, callback) {
callback = callback || function() {};
function register() { function register() {
Plugins.loadedHooks[data.hook] = Plugins.loadedHooks[data.hook] || []; Plugins.loadedHooks[data.hook] = Plugins.loadedHooks[data.hook] || [];
Plugins.loadedHooks[data.hook].push(data); Plugins.loadedHooks[data.hook].push(data);
if (typeof callback === 'function') { callback();
callback();
}
} }
if (!data.hook) { if (!data.hook) {
return winston.warn('[plugins/' + id + '] registerHook called with invalid data.hook', data); winston.warn('[plugins/' + id + '] registerHook called with invalid data.hook', data);
return callback();
} }
var method; var method;
@ -69,6 +69,7 @@ module.exports = function(Plugins) {
register(); register();
} else { } else {
winston.warn('[plugins/' + id + '] Hook method mismatch: ' + data.hook + ' => ' + data.method); winston.warn('[plugins/' + id + '] Hook method mismatch: ' + data.hook + ' => ' + data.method);
return callback();
} }
} }
}; };

Loading…
Cancel
Save