This commit is contained in:
Louis Lam 2023-12-04 20:04:31 +08:00
parent 20a68a16f5
commit 21a6b4a131

View file

@ -4,7 +4,7 @@ const { sendInfo } = require("../client");
const { checkLogin } = require("../util-server");
const GameResolver = require("gamedig/lib/GameResolver");
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
const fs = require("fs");
const fs = require("fs/promises");
const path = require("path");
let gameResolver = new GameResolver();
@ -85,17 +85,17 @@ module.exports.generalSocketHandler = (socket, server) => {
}
});
socket.on("getPushExample", (language, callback) => {
socket.on("getPushExample", async (language, callback) => {
try {
let dir = path.join("./extra/push-examples", language);
let files = fs.readdirSync(dir);
let files = await fs.readdir(dir);
for (let file of files) {
if (file.startsWith("index.")) {
callback({
ok: true,
code: fs.readFileSync(path.join(dir, file), "utf8"),
code: await fs.readFile(path.join(dir, file), "utf8"),
});
return;
}