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
if ( ! fs . existsSync ( filename _custom ) )
fs . writeFileSync ( filename _custom , ` # Custom settings file. This file overrides server/settings.default.toml - refer there of example of settings you can override. \n \n ` ) ;
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 ;