From a8d0cb5b197b950b09c61169600eb1614931d3cc Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 22 Oct 2020 20:51:20 -0600 Subject: [PATCH] Move database directory to constants --- src/constants.ts | 3 ++- src/main.ts | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 9ee6fb8..62f1d4c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1 +1,2 @@ -export const LOG_NAME: string = `Secret Hitler`; \ No newline at end of file +export const LOG_NAME: string = `Secret Hitler`; +export const DB_DIR: string = `data`; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index d5794c2..b4a9982 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,11 +4,11 @@ import * as sio from "socket.io"; import { writeFileSync } from "fs"; import { Game } from "./utils/Game"; import { Vote } from "./events/Vote"; -import { LOG_NAME } from "./constants"; import { KillGame } from "./events/KillGame"; import { JoinGame } from "./events/JoinGame"; import { HostGame } from "./events/HostGame"; import { StartGame } from "./events/StartGame"; +import { LOG_NAME, DB_DIR } from "./constants"; import { VetoConfirm } from "./events/VetoConfirm"; import { VetoRequest } from "./events/VetoRequest"; import { RemovePlayer } from "./events/RemovePlayer"; @@ -51,8 +51,6 @@ export var log: Logger = new Logger({ export var active_games: {[key: string]: Game} = {}; -const db_dir = `data`; - /** * This function is called whenever the main node process is terminated for * whatever reason. It cleans up and writes all the active games to the disk. @@ -62,7 +60,7 @@ function clean_up() { for (var code in active_games) { log.debug(`Writing game: ${code} to disk`); log.silly(active_games[code].toString()); - // writeFileSync(`${db_dir}/${code}`, active_games[code].toJSON()); + // writeFileSync(`${DB__DIR}/${code}`, active_games[code].toJSON()); }; log.info(`Finished cleanup. Exiting.`); process.exit(0);