mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
简化模块加载
deprecated hydro-build
This commit is contained in:
1 parent
8aef05a375
commit
8f6968bbbd
41 files changed
+1361
-1957
No files matched your search
+7
-13
@@ -1,17 +1,11 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { defaults } from 'lodash';
|
||||
|
||||
let f = path.resolve(process.cwd(), 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve(os.homedir(), '.config', 'hydro', 'config.json');
|
||||
if (!fs.existsSync(f)) f = path.resolve('/config/config.json');
|
||||
const t = JSON.parse(fs.readFileSync(f).toString());
|
||||
|
||||
export default defaults(t, {
|
||||
name: 'hydro',
|
||||
host: '127.0.0.1',
|
||||
port: 27017,
|
||||
username: '',
|
||||
password: '',
|
||||
});
|
||||
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('/config/config.json');
|
||||
return JSON.parse(fs.readFileSync(f).toString());
|
||||
}
|
||||
Reference in new issue
Block a user