文件结构更改

This commit is contained in:
undefined committed 2020-08-04 13:42:42 +08:00
1 parent b3af28dc43
commit 1f1d12ad73
109 files changed
+544 -3296

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
export default function load() {
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;
let result: any = {};
try {
result = JSON.parse(fs.readFileSync(f).toString());
} catch (e) {
console.error('Cannot read config file', e);
result = {};
}
return result;
}