Paths #240
@ -102,13 +102,18 @@ var Config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
const ConfigPath = join(resolve(homedir(), "bds_core"), "BdsConfig.yaml")
|
const ConfigPath = join(bds_dir, "BdsConfig.yaml")
|
||||||
|
|
||||||
const SaveConfig = () => writeFileSync(ConfigPath, yaml.dump(Config));
|
const SaveConfig = () => writeFileSync(ConfigPath, yaml.dump(Config));
|
||||||
process.on("exit", () => SaveConfig());
|
process.on("exit", () => SaveConfig());
|
||||||
|
|
||||||
if (existsSync(ConfigPath)) Config = deepmerge(Config, yaml.load(readFileSync(ConfigPath, "utf8")));
|
if (existsSync(ConfigPath)) {
|
||||||
else writeFileSync(ConfigPath, yaml.dump(Config))
|
Config.ban = [];
|
||||||
|
Config.server.BackupCron = [];
|
||||||
|
Config.telegram.admins = [];
|
||||||
|
Config.telegram.ban = [];
|
||||||
|
Config = deepmerge(Config, yaml.load(readFileSync(ConfigPath, "utf8")));
|
||||||
|
} else writeFileSync(ConfigPath, yaml.dump(Config))
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
if (!(existsSync(Config.paths["backups"]))) mkdirSync(Config.paths["backups"], {recursive: true})
|
if (!(existsSync(Config.paths["backups"]))) mkdirSync(Config.paths["backups"], {recursive: true})
|
||||||
@ -123,6 +128,7 @@ const ServersPaths = {
|
|||||||
dragonfly: join(Config.paths.servers, "Dragonfly_go"),
|
dragonfly: join(Config.paths.servers, "Dragonfly_go"),
|
||||||
spigot: join(Config.paths.servers, "Spigot")
|
spigot: join(Config.paths.servers, "Spigot")
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.getOwnPropertyNames(ServersPaths).map(Servers => ServersPaths[Servers]).forEach(Servers => {
|
Object.getOwnPropertyNames(ServersPaths).map(Servers => ServersPaths[Servers]).forEach(Servers => {
|
||||||
if (!(existsSync(Servers))) {
|
if (!(existsSync(Servers))) {
|
||||||
console.log(`Creating the ${basename(Servers)} Folder`);
|
console.log(`Creating the ${basename(Servers)} Folder`);
|
||||||
@ -200,7 +206,7 @@ const GetTempHost = () => Config.bds.enable_tmp_host
|
|||||||
function UpdateTempHost(enable = false){
|
function UpdateTempHost(enable = false){
|
||||||
// Check Boolean
|
// Check Boolean
|
||||||
if (typeof enable !== "boolean") {console.log("Use Boolean, default false"); enable = false;}
|
if (typeof enable !== "boolean") {console.log("Use Boolean, default false"); enable = false;}
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
Config.bds.enable_tmp_host = enable
|
Config.bds.enable_tmp_host = enable
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
|
Reference in New Issue
Block a user