mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: bail: change to async
This commit is contained in:
1 parent
8c83a79bee
commit
c184d94dae
2 files changed
+4
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.29.20",
|
"version": "2.29.21",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -173,11 +173,12 @@ export async function serial<K extends keyof EventMap>(name: K, ...args: Paramet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bail<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): ReturnType<EventMap[K]> {
|
export async function bail<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): ReturnType<EventMap[K]> {
|
||||||
if (argv.options.showBus && name !== 'message/log') logger.debug('bail: %s %o', name, args);
|
if (argv.options.showBus && name !== 'message/log') logger.debug('bail: %s %o', name, args);
|
||||||
const hooks = Array.from(_hooks[name] || []);
|
const hooks = Array.from(_hooks[name] || []);
|
||||||
for (const callback of hooks) {
|
for (const callback of hooks) {
|
||||||
const result = callback.apply(this, args);
|
let result = callback.apply(this, args);
|
||||||
|
if (result instanceof Promise) result = await result;
|
||||||
if (isBailed(result)) return result;
|
if (isBailed(result)) return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in new issue
Block a user