import fs, { readFileSync } from "fs"; import path from "path"; import process from "process"; import moment from "moment"; let configJson; // if (process.env.IS_ELECTRON) { const dirName = process.env.PORTABLE_EXECUTABLE_DIR; if (dirName) { configJson = readFileSync(path.join(dirName || "", "config.json")); } else { configJson = readFileSync(path.join(__dirname, "../config.json")); } const store = JSON.parse(configJson.toString()); export default store; const timeLog = path.join(__dirname, "../../logs/time.log"); let syncTime = {}; if (fs.existsSync(path.join(__dirname, "../../logs/time.log"))) { try { syncTime = readFileSync(timeLog).toJSON(); } catch (err) { syncTime = {}; } } store["syncTime"] = syncTime; export function updateSyncTime(): void { if (env.server && env.exam) { syncTime[env.server.host + "_" + env.exam.id] = moment().format( "YYYY-MM-DD HH:mm:ss" ); store["syncTime"] = syncTime; fs.writeFileSync(timeLog, JSON.stringify(syncTime)); } }