core: load ts files only

This commit is contained in:
undefined committed 2024-01-07 17:12:59 +08:00
1 parent ac1699665c
commit 5369d8d5eb
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@ export const service = getLoader('service', 'service');
export async function builtinModel(ctx: Context) {
const modelDir = path.resolve(__dirname, '..', 'model');
const models = await fs.readdir(modelDir);
for (const t of models) {
for (const t of models.filter((i) => i.endsWith('.ts'))) {
const q = path.resolve(modelDir, t);
if ('apply' in require(q)) ctx.loader.reloadPlugin(ctx, q, {}, `hydrooj/model/${t.split('.')[0]}`);
}
+1 -1
View File
@@ -56,7 +56,7 @@ export async function apply(ctx: Context) {
const handlerDir = path.resolve(__dirname, '..', 'handler');
const handlers = await fs.readdir(handlerDir);
for (const h of handlers) {
for (const h of handlers.filter((i) => i.endsWith('.ts'))) {
ctx.loader.reloadPlugin(ctx, path.resolve(handlerDir, h), {}, `hydrooj/handler/${h.split('.')[0]}`);
}
await handler(pending, fail, ctx);