2019-05-23 19:10:06 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-05-23 21:26:31 +00:00
|
|
|
import path from 'path';
|
2019-05-23 19:10:06 +00:00
|
|
|
import fs from 'fs';
|
|
|
|
|
|
|
|
import toml from '@iarna/toml';
|
|
|
|
|
2019-05-23 21:26:31 +00:00
|
|
|
import apply_settings from '../Helpers/apply_settings.mjs';
|
2019-05-23 19:10:06 +00:00
|
|
|
|
2019-05-23 21:26:31 +00:00
|
|
|
const root_dir = path.dirname(process.argv[1]);
|
2019-05-23 19:10:06 +00:00
|
|
|
|
2019-05-23 21:26:31 +00:00
|
|
|
let filename_default = path.resolve(root_dir, "./settings.default.toml"),
|
|
|
|
filename_custom = path.resolve(root_dir, "../settings.toml");
|
2019-05-23 19:10:06 +00:00
|
|
|
|
2019-07-16 17:08:39 +00:00
|
|
|
if(!fs.existsSync(filename_custom)) {
|
|
|
|
fs.writeFileSync(
|
|
|
|
filename_custom,
|
|
|
|
`# Custom settings file. This file overrides server/settings.default.toml - refer there for examples of settings you can override.\n\n`, {
|
|
|
|
mode: 0o600
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
2019-05-23 19:10:06 +00:00
|
|
|
let settings = toml.parse(fs.readFileSync(filename_default, "utf-8")),
|
2019-05-23 21:26:31 +00:00
|
|
|
settings_override = toml.parse(fs.readFileSync(filename_custom, "utf-8"));
|
2019-05-23 19:10:06 +00:00
|
|
|
|
|
|
|
apply_settings(settings, settings_override);
|
|
|
|
|
|
|
|
export default settings;
|