node-karin 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -337,7 +337,7 @@ class PluginLoader {
|
|
|
337
337
|
logger.debug(`载入插件 [${plugin}]${_path ? `${common.getRelPath(_path)}` : ''}[${file}][${Class.name}]`);
|
|
338
338
|
if (Class.rule.length) {
|
|
339
339
|
for (const val of Class.rule) {
|
|
340
|
-
|
|
340
|
+
const fnc = async () => {
|
|
341
341
|
const log = val.log === false
|
|
342
342
|
? (id, log) => logger.debug('mark', id, log)
|
|
343
343
|
: (id, log) => logger.bot('mark', id, log);
|
|
@@ -354,12 +354,13 @@ class PluginLoader {
|
|
|
354
354
|
rank: val.priority || Class.priority || 10000,
|
|
355
355
|
reg: val.reg instanceof RegExp ? val.reg : new RegExp(val.reg),
|
|
356
356
|
}, Fn);
|
|
357
|
-
}
|
|
357
|
+
};
|
|
358
|
+
list.push(fnc());
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
if (Class.task.length) {
|
|
361
362
|
for (const val of Class.task) {
|
|
362
|
-
|
|
363
|
+
const fnc = async () => {
|
|
363
364
|
if (!val.name)
|
|
364
365
|
throw TypeError(`[${plugin}][${file}] 定时任务name错误`);
|
|
365
366
|
if (!val.cron)
|
|
@@ -373,13 +374,12 @@ class PluginLoader {
|
|
|
373
374
|
log,
|
|
374
375
|
cron: val.cron,
|
|
375
376
|
}, Fn);
|
|
376
|
-
}
|
|
377
|
+
};
|
|
378
|
+
list.push(fnc());
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
381
|
/** init */
|
|
380
|
-
list.push(
|
|
381
|
-
'init' in Class && typeof Class.init === 'function' && await Class.init();
|
|
382
|
-
});
|
|
382
|
+
list.push('init' in Class && typeof Class.init === 'function' ? Class.init() : Promise.resolve());
|
|
383
383
|
return true;
|
|
384
384
|
});
|
|
385
385
|
await Promise.all(list);
|
|
@@ -461,7 +461,7 @@ class PluginLoader {
|
|
|
461
461
|
perm: info.perm,
|
|
462
462
|
rank: info.rank,
|
|
463
463
|
reg: info.reg,
|
|
464
|
-
type: 'function',
|
|
464
|
+
type: App ? 'class' : 'function',
|
|
465
465
|
});
|
|
466
466
|
return true;
|
|
467
467
|
}
|