优化loader

pull/10/head
undefined 4 years ago
parent 61c4d38521
commit 32a6d2de13

@ -3,6 +3,7 @@
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { argv } from 'yargs';
export const builtinLib = [
'jwt', 'download', 'i18n', 'mail', 'useragent',
@ -53,6 +54,7 @@ export async function handler(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Handler Load Fail: ${i}`);
if (argv.debug) console.error(e);
}
}
}
@ -75,6 +77,7 @@ export async function locale(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Locale Load Fail: ${i}`);
if (argv.debug) console.error(e);
}
}
}
@ -104,6 +107,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
}
} catch (e) {
console.error(`Config Load Fail: ${i}`);
if (argv.debug) console.error(e);
}
}
}
@ -125,6 +129,7 @@ export async function template(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Template Load Fail: ${i}`);
if (argv.debug) console.error(e);
}
}
}
@ -155,6 +160,7 @@ export async function model(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Model Load Fail: ${i}`);
if (argv.debug) console.error(e);
}
}
}
@ -172,7 +178,7 @@ export async function lib(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Lib Load Fail: ${i}`);
console.error(e);
if (argv.debug) console.error(e);
}
}
}
@ -190,7 +196,7 @@ export async function service(pending: string[], fail: string[]) {
} catch (e) {
fail.push(i);
console.error(`Service Load Fail: ${i}`);
console.error(e);
if (argv.debug) console.error(e);
}
}
}
@ -207,7 +213,7 @@ export async function script(pending: string[], fail: string[], active: string[]
} catch (e) {
fail.push(i);
console.error(`Script Load Fail: ${i}`);
console.error(e);
if (argv.debug) console.error(e);
}
}
active.push(i);

@ -12,28 +12,30 @@ import AdmZip from 'adm-zip';
export * from './interface';
global.Hydro = {
stat: { reqCount: 0 },
handler: {},
// @ts-ignore
service: {},
// @ts-ignore
model: {},
script: {},
// @ts-ignore
lib: {},
ui: {
manifest: {},
nav: [],
template: {},
},
// @ts-ignore
error: {},
locales: {},
postInit: [],
};
global.onDestory = [];
global.addons = [];
if (!global.Hydro) {
global.Hydro = {
stat: { reqCount: 0 },
handler: {},
// @ts-ignore
service: {},
// @ts-ignore
model: {},
script: {},
// @ts-ignore
lib: {},
ui: {
manifest: {},
nav: [],
template: {},
},
// @ts-ignore
error: {},
locales: {},
postInit: [],
};
global.onDestory = [];
global.addons = [];
}
if (argv.debug) {
console.log(process.argv);

@ -524,6 +524,7 @@ Problem Solution: 题解列表
Problem Tags Visibility: 题目标签可见性
problem_create: 创建题目
problem_detail: 题目详情
problem_detail: 题目详情
problem_edit: 编辑题目
problem_import: 导入题目
problem_main: 题库

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.11.8",
"version": "2.11.9",
"main": "dist/loader.js",
"bin": "bin/hydrooj.js",
"repository": "https://github.com/hydro-dev/Hydro.git",

Loading…
Cancel
Save