feat: commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import * as fs from 'fs-extra';
|
||||
import * as yaml from 'js-yaml';
|
||||
import * as path from 'path';
|
||||
|
||||
const ENV_NAME = {
|
||||
development: 'dev',
|
||||
production: 'prod',
|
||||
};
|
||||
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
|
||||
export function getConfig() {
|
||||
const filePath = path.join(__dirname, './', `${ENV_NAME[env]}.yaml`);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`Can not find config file: ${filePath}`);
|
||||
}
|
||||
return yaml.load(fs.readFileSync(filePath, 'utf-8')) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
}
|
||||
Reference in New Issue
Block a user