2023-01-24 14:10:39 +00:00
|
|
|
import yml from 'require-yml';
|
|
|
|
import path from 'path';
|
|
|
|
import fs from 'fs-extra';
|
|
|
|
|
2024-03-04 10:42:48 +00:00
|
|
|
export default function getConfig(env = 'local') {
|
2023-01-24 14:10:39 +00:00
|
|
|
const {pathname: root} = new URL('../', import.meta.url);
|
|
|
|
let conf = yml(path.join(root, 'config.yml'));
|
2024-03-04 10:42:48 +00:00
|
|
|
const localConfFile = path.join(root, `config.${env}.yml`);
|
2023-01-24 14:10:39 +00:00
|
|
|
if (fs.existsSync(localConfFile))
|
|
|
|
conf = Object.assign({}, conf, yml(localConfFile));
|
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|