mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
feat: 从~/.hydro/env读取环境变量
This commit is contained in:
1 parent
e3dad8ff60
commit
c6b67bb1a8
7 files changed
+26
-13
No files matched your search
@@ -6,6 +6,14 @@ import { Logger } from './logger';
|
||||
const logger = new Logger('options');
|
||||
|
||||
export = function load() {
|
||||
const envFile = path.resolve(os.homedir(), '.hydro', 'env');
|
||||
if (fs.existsSync(envFile)) {
|
||||
const content = fs.readFileSync(envFile).toString();
|
||||
for (const line of content.split('\n')) {
|
||||
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');
|
||||
|
||||
Reference in new issue
Block a user