2017-10-22 09:10:33 +08:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-15 11:31:44 +08:00
|
|
|
const ini = require('ini');
|
|
|
|
const fs = require('fs');
|
2017-10-24 11:30:23 +08:00
|
|
|
const dataDir = require('./data_dir');
|
2017-12-25 04:12:18 +08:00
|
|
|
const path = require('path');
|
2017-12-28 05:44:15 +08:00
|
|
|
const resource_dir = require('./resource_dir');
|
2017-10-15 11:31:44 +08:00
|
|
|
|
2017-12-28 05:44:15 +08:00
|
|
|
const configSampleFilePath = path.resolve(resource_dir.RESOURCE_DIR, "config-sample.ini");
|
2017-12-25 04:12:18 +08:00
|
|
|
|
|
|
|
const configFilePath = dataDir.TRILIUM_DATA_DIR + '/config.ini';
|
|
|
|
|
|
|
|
if (!fs.existsSync(configFilePath)) {
|
|
|
|
const configSample = fs.readFileSync(configSampleFilePath).toString('utf8');
|
|
|
|
|
|
|
|
fs.writeFileSync(configFilePath, configSample);
|
|
|
|
}
|
|
|
|
|
|
|
|
const config = ini.parse(fs.readFileSync(configFilePath, 'utf-8'));
|
2017-10-15 11:31:44 +08:00
|
|
|
|
|
|
|
module.exports = config;
|