mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: 使用web下发的langs.yaml
This commit is contained in:
1 parent
0273bfe198
commit
33d7c70ef6
2 files changed
+1
-13
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.7.0",
|
"version": "2.7.1",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import log from './log';
|
|
||||||
|
|
||||||
const argv = cac().parse();
|
const argv = cac().parse();
|
||||||
let CONFIG_FILE = path.resolve(os.homedir(), '.config', 'hydro', 'judge.yaml');
|
let CONFIG_FILE = path.resolve(os.homedir(), '.config', 'hydro', 'judge.yaml');
|
||||||
let LANGS_FILE = path.resolve(os.homedir(), '.config', 'hydro', 'langs.yaml');
|
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
cache_dir: path.resolve(os.homedir(), '.cache', 'hydro', 'judge'),
|
cache_dir: path.resolve(os.homedir(), '.cache', 'hydro', 'judge'),
|
||||||
@@ -47,9 +45,6 @@ if (!global.Hydro) {
|
|||||||
if (process.env.CONFIG_FILE || argv.options.config) {
|
if (process.env.CONFIG_FILE || argv.options.config) {
|
||||||
CONFIG_FILE = path.resolve(process.env.CONFIG_FILE || argv.options.config);
|
CONFIG_FILE = path.resolve(process.env.CONFIG_FILE || argv.options.config);
|
||||||
}
|
}
|
||||||
if (process.env.LANGS_FILE || argv.options.langs) {
|
|
||||||
LANGS_FILE = path.resolve(process.env.LANGS_FILE || argv.options.langs);
|
|
||||||
}
|
|
||||||
if (process.env.TEMP_DIR || argv.options.tmp) {
|
if (process.env.TEMP_DIR || argv.options.tmp) {
|
||||||
config.tmp_dir = path.resolve(process.env.TEMP_DIR || argv.options.tmp);
|
config.tmp_dir = path.resolve(process.env.TEMP_DIR || argv.options.tmp);
|
||||||
}
|
}
|
||||||
@@ -61,11 +56,4 @@ if (!global.Hydro) {
|
|||||||
}
|
}
|
||||||
const configFile = fs.readFileSync(CONFIG_FILE).toString();
|
const configFile = fs.readFileSync(CONFIG_FILE).toString();
|
||||||
config = { ...config, ...yaml.load(configFile) as any };
|
config = { ...config, ...yaml.load(configFile) as any };
|
||||||
if (fs.existsSync(LANGS_FILE)) config.langs = 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.load(fs.readFileSync(file).toString()) as any;
|
|
||||||
config.langs = content.langs.default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user