mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: 支持修改tags & workspace: upgrade to js-yaml@4
This commit is contained in:
1 parent
87a4bc8bfa
commit
3d9acf2c1a
18 files changed
+38
-36
No files matched your search
@@ -299,7 +299,7 @@ export default async function readCases(folder: string, cfg: Record<string, any>
|
||||
const yamlConfig = path.resolve(folder, 'config.yaml');
|
||||
let config;
|
||||
if (fs.existsSync(yamlConfig)) {
|
||||
config = { ...yaml.safeLoad(fs.readFileSync(yamlConfig).toString()) as object, ...cfg };
|
||||
config = { ...yaml.load(fs.readFileSync(yamlConfig).toString()) as object, ...cfg };
|
||||
} else if (fs.existsSync(iniConfig)) {
|
||||
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg };
|
||||
} else config = cfg;
|
||||
|
||||
@@ -9,7 +9,7 @@ export = async function compile(
|
||||
lang: string, code: string, target: string, copyIn: any, next?: Function,
|
||||
): Promise<Execute> {
|
||||
const LANGS = global.Hydro
|
||||
? yaml.safeLoad(await global.Hydro.model.system.get('hydrojudge.langs'))
|
||||
? yaml.load(global.Hydro.model.system.get('hydrojudge.langs'))
|
||||
: require('./config').LANGS;
|
||||
if (!LANGS[lang]) throw new SystemError('Unsupported language {0}.', [lang]);
|
||||
const info = LANGS[lang];
|
||||
|
||||
@@ -47,12 +47,12 @@ if (process.env.EXECUTION_HOST || argv.execute) {
|
||||
EXECUTION_HOST = path.resolve(process.env.EXECUTION_HOST || argv.execute as string);
|
||||
}
|
||||
if (!global.Hydro) {
|
||||
if (fs.existsSync(LANGS_FILE)) LANGS = yaml.safeLoad(fs.readFileSync(LANGS_FILE).toString());
|
||||
if (fs.existsSync(LANGS_FILE)) LANGS = yaml.load(fs.readFileSync(LANGS_FILE).toString());
|
||||
else {
|
||||
log.error('Language file not found, using default.');
|
||||
const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml');
|
||||
const content = yaml.safeLoad(fs.readFileSync(file).toString()) as any;
|
||||
LANGS = yaml.safeLoad(content.langs.default) as any;
|
||||
const content = yaml.load(fs.readFileSync(file).toString()) as any;
|
||||
LANGS = yaml.load(content.langs.default) as any;
|
||||
}
|
||||
if (!(fs.existsSync(LANGS_FILE) || global.Hydro)) {
|
||||
fs.ensureDirSync(path.dirname(LANGS_FILE));
|
||||
|
||||
@@ -57,7 +57,7 @@ async function daemon() {
|
||||
if (CONFIG) config = CONFIG;
|
||||
else {
|
||||
config = (await fs.readFile(CONFIG_FILE)).toString();
|
||||
config = yaml.safeLoad(config);
|
||||
config = yaml.load(config);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('配置文件无效或未找到。');
|
||||
@@ -85,7 +85,7 @@ async function daemon() {
|
||||
if (hosts[i].config.cookie) cfg.hosts[i].cookie = hosts[i].config.cookie;
|
||||
if (hosts[i].config.detail) cfg.hosts[i].detail = hosts[i].config.detail;
|
||||
}
|
||||
await fs.writeFile(CONFIG_FILE, yaml.safeDump(cfg));
|
||||
await fs.writeFile(CONFIG_FILE, yaml.dump(cfg));
|
||||
});
|
||||
}
|
||||
while ('Orz twd2') {
|
||||
|
||||
Reference in new issue
Block a user