mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
Server: Reimplemented config system
This commit is contained in:
parent
85ee5da025
commit
b7de1e3d27
6 changed files with 107 additions and 114 deletions
18
utils/loadConfig.js
Normal file
18
utils/loadConfig.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const { readFile } = require('fs/promises');
|
||||
const checkFileExists = require('../utils/checkFileExists');
|
||||
const initConfig = require('../utils/init/initConfig');
|
||||
|
||||
const loadConfig = async () => {
|
||||
const configExists = await checkFileExists('data/config.json');
|
||||
|
||||
if (!configExists) {
|
||||
await initConfig();
|
||||
}
|
||||
|
||||
const config = await readFile('data/config.json', 'utf-8');
|
||||
const parsedConfig = JSON.parse(config);
|
||||
|
||||
return parsedConfig;
|
||||
};
|
||||
|
||||
module.exports = loadConfig;
|
Loading…
Add table
Add a link
Reference in a new issue