LoRaWAN-Signal-Mapping/server/bootstrap/settings.mjs

24 lines
772 B
JavaScript
Raw Normal View History

"use strict";
import path from 'path';
import fs from 'fs';
import toml from '@iarna/toml';
import apply_settings from '../Helpers/apply_settings.mjs';
const root_dir = path.dirname(process.argv[1]);
let filename_default = path.resolve(root_dir, "./settings.default.toml"),
filename_custom = path.resolve(root_dir, "../settings.toml");
if(!fs.existsSync(filename_custom))
2019-07-16 15:32:24 +00:00
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`);
let settings = toml.parse(fs.readFileSync(filename_default, "utf-8")),
settings_override = toml.parse(fs.readFileSync(filename_custom, "utf-8"));
apply_settings(settings, settings_override);
export default settings;