Commit iniziale
This commit is contained in:
20
services/configService.js
Normal file
20
services/configService.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
const configPath = path.join(os.homedir(), '.cad-router-config.json');
|
||||
const defaultConfigPath = path.join(__dirname, '..', 'config', 'defaultConfig.json');
|
||||
|
||||
async function loadConfig() {
|
||||
if (await fs.pathExists(configPath)) {
|
||||
return fs.readJson(configPath);
|
||||
}
|
||||
|
||||
const defaultConfig = await fs.readJson(defaultConfigPath);
|
||||
await fs.writeJson(configPath, defaultConfig, { spaces: 2 });
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
loadConfig.getConfigPath = () => configPath;
|
||||
|
||||
module.exports = { loadConfig };
|
||||
Reference in New Issue
Block a user