mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
use findFile() api
This commit is contained in:
1 parent
8a8e312ca4
commit
9a538130ee
10 files changed
+105
-52
No files matched your search
@@ -43,6 +43,7 @@
|
||||
"@types/inquirer": "^7.3.1",
|
||||
"@types/js-yaml": "^4.0.0",
|
||||
"@types/koa": "^2.13.1",
|
||||
"@types/koa-compress": "^4.0.1",
|
||||
"@types/koa-router": "^7.4.1",
|
||||
"@types/koa-static-cache": "^5.1.0",
|
||||
"@types/lodash": "^4.14.168",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { findFileSync } from '@hydrooj/utils/lib/utils';
|
||||
import { Logger } from './logger';
|
||||
|
||||
const logger = new Logger('options');
|
||||
@@ -13,13 +14,8 @@ export = function load() {
|
||||
process.env[line.split('=')[0]] = line.split('=')[1];
|
||||
}
|
||||
}
|
||||
|
||||
let f = path.resolve(process.cwd(), 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve(__dirname, 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve(os.homedir(), '.config', 'hydro', 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve(os.homedir(), '.hydro', 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve('/config/config.json');
|
||||
if (!fs.existsSync(f)) return null;
|
||||
const f = findFileSync('config.json', false);
|
||||
if (!f) return null;
|
||||
let result: any = {};
|
||||
try {
|
||||
result = JSON.parse(fs.readFileSync(f).toString());
|
||||
|
||||
Reference in new issue
Block a user