mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
hooks: Rewrite callAll
and aCallAll
for consistency
Rewrite the `callAll` and `aCallAll` functions to support all reasonable hook behaviors and to report errors for unreasonable behaviors (e.g., calling the callback twice). Now a hook function like the following works as expected when invoked by `aCallAll`: ``` exports.myHookFn = (hookName, context, cb) => { cb('some value'); return; }; ```
This commit is contained in:
parent
79119baf58
commit
36aceb3aba
6 changed files with 1400 additions and 74 deletions
|
@ -1,7 +1,10 @@
|
|||
/* global __dirname, exports, require */
|
||||
|
||||
function m(mod) { return __dirname + '/../../src/' + mod; }
|
||||
|
||||
const apiHandler = require(m('node/handler/APIHandler'));
|
||||
const log4js = require(m('node_modules/log4js'));
|
||||
const process = require('process');
|
||||
const server = require(m('node/server'));
|
||||
const settings = require(m('node/utils/Settings'));
|
||||
const supertest = require(m('node_modules/supertest'));
|
||||
|
@ -18,6 +21,10 @@ exports.logger = log4js.getLogger('test');
|
|||
|
||||
const logLevel = exports.logger.level;
|
||||
|
||||
// Mocha doesn't monitor unhandled Promise rejections, so convert them to uncaught exceptions.
|
||||
// https://github.com/mochajs/mocha/issues/2640
|
||||
process.on('unhandledRejection', (reason, promise) => { throw reason; });
|
||||
|
||||
exports.init = async function() {
|
||||
if (inited) return exports.agent;
|
||||
inited = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue