v1.18.x
Barış Soner Uşaklı 7 years ago
parent 53afa552d0
commit b55087dab7

@ -82,20 +82,23 @@ module.exports = function (Plugins) {
var hookList = Plugins.loadedHooks[hook];
var hookType = hook.split(':')[0];
switch (hookType) {
case 'filter':
fireFilterHook(hook, hookList, params, callback);
break;
case 'action':
fireActionHook(hook, hookList, params, callback);
break;
case 'static':
fireStaticHook(hook, hookList, params, callback);
break;
default:
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
break;
try {
switch (hookType) {
case 'filter':
fireFilterHook(hook, hookList, params, callback);
break;
case 'action':
fireActionHook(hook, hookList, params, callback);
break;
case 'static':
fireStaticHook(hook, hookList, params, callback);
break;
default:
winston.warn('[plugins] Unknown hookType: ' + hookType + ', hook : ' + hook);
break;
}
} catch (err) {
callback(err);
}
};

@ -70,6 +70,20 @@ describe('Plugins', function () {
});
});
it('should not crash if there is an exception in a hook', function (done) {
function filterMethod(data, callback) {
var crash;
crash.a = 5;
callback(null, data);
}
assert(err);
assert.equal(err.message, 'Cannot set property \'a\' of undefined');
done();
});
});
it('should get plugin data from nbbpm', function (done) {
plugins.get('nodebb-plugin-markdown', function (err, data) {
assert.ifError(err);

Loading…
Cancel
Save