core: bug fixes

This commit is contained in:
undefined committed 2022-10-06 02:53:22 +08:00
1 parent 5d340608db
commit 2daa7e2034
11 files changed
+36 -34

No files matched your search

+2 -1
View File
@@ -9,6 +9,7 @@ import { Context } from '../context';
import i18n from '../lib/i18n';
import { Logger } from '../logger';
import * as bus from '../service/bus';
import { unwrapExports } from '../utils';
const logger = new Logger('common');
@@ -37,7 +38,7 @@ const getLoader = (type: LoadTask, filename: string) => async function loader(pe
const p = locateFile(i, [`${filename}.ts`, `${filename}.js`]);
if (p && !fail.includes(i)) {
try {
const m = require(p);
const m = unwrapExports(require(p));
if (m.apply) ctx.loader.reloadPlugin(ctx, p, {});
else logger.info(`${type.replace(/^(.)/, (t) => t.toUpperCase())} init: %s`, i);
} catch (e) {
+1 -1
View File
@@ -60,6 +60,7 @@ export async function apply(ctx: Context) {
}
await handler(pending, fail, ctx);
await addon(pending, fail, ctx);
await ctx.lifecycle.flush();
for (const i in global.Hydro.handler) await global.Hydro.handler[i]();
const scriptDir = path.resolve(__dirname, '..', 'script');
for (const h of await fs.readdir(scriptDir)) {
@@ -68,7 +69,6 @@ export async function apply(ctx: Context) {
await ctx.lifecycle.flush();
await script(pending, fail, ctx);
await ctx.lifecycle.flush();
await sleep(1000); // lifecycle.flush won't wait for async function
await ctx.parallel('app/started');
if (process.env.NODE_APP_INSTANCE === '0') {
const scripts = require('../upgrade').default;