123456789101112131415161718192021222324252627282930313233 |
- import fs from "fs";
- import path from "path";
- import moment from "moment";
- import env from "./env";
- console.log(__dirname);
- const configJson = fs.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 = fs.readFileSync(timeLog).toJSON();
- } catch (err) {
- syncTime = {};
- }
- }
- store["syncTime"] = syncTime;
- // module.exports = store;
- 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));
- }
- }
|