mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
fix serialization and race cond
This commit is contained in:
parent
d188a93a6c
commit
c365c86a49
3 changed files with 18 additions and 27 deletions
|
@ -7,6 +7,7 @@
|
|||
import { Logger } from "@utils/Logger";
|
||||
import * as Webpack from "@webpack";
|
||||
import { patches } from "plugins";
|
||||
import { initWs } from "plugins/devCompanion.dev/initWs";
|
||||
|
||||
import { loadLazyChunks } from "./loadLazyChunks";
|
||||
import { reporterData } from "./reporterData";
|
||||
|
@ -78,11 +79,13 @@ async function runReporter() {
|
|||
}
|
||||
}
|
||||
|
||||
// if we are running the reporter with companion integration, send the list to vscode as soon as we can
|
||||
if(IS_COMPANION_TEST)
|
||||
initWs();
|
||||
ReporterLogger.log("Finished test");
|
||||
} catch (e) {
|
||||
ReporterLogger.log("A fatal error occurred:", e);
|
||||
}
|
||||
console.log(reporterData);
|
||||
}
|
||||
|
||||
// imported in webpack for reporterData, wrap to avoid running reporter
|
||||
|
|
|
@ -20,7 +20,6 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
||||
import { reporterData } from "debug/reporterData";
|
||||
|
||||
import { initWs, socket, stopWs } from "./initWs";
|
||||
console.log("imported");
|
||||
|
@ -58,8 +57,8 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
start() {
|
||||
console.log(123);
|
||||
console.log(reporterData);
|
||||
// if were running the reporter, we need to initws in the reporter file to avoid a race condition
|
||||
if (!IS_COMPANION_TEST)
|
||||
initWs();
|
||||
},
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import { showNotification } from "@api/Notifications";
|
||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||
import { Patch } from "@utils/types";
|
||||
import { filters, findAll, search, wreq } from "@webpack";
|
||||
import { reporterData } from "debug/reporterData";
|
||||
|
||||
|
@ -40,29 +39,19 @@ export function initWs(isManual = false) {
|
|||
data: Object.keys(wreq.m),
|
||||
ok: true,
|
||||
});
|
||||
// if we are running the reporter with companion integration, send the list to vscode as soon as we can
|
||||
|
||||
if (IS_COMPANION_TEST) {
|
||||
const toSend = reporterData;
|
||||
for (const i in toSend.failedPatches) {
|
||||
for (const j in toSend.failedPatches[i]) {
|
||||
const patch: Patch = toSend.failedPatches[i][j];
|
||||
if (patch.find instanceof RegExp)
|
||||
patch.find = String(patch.find);
|
||||
if (!Array.isArray(patch.replacement))
|
||||
patch.replacement = [patch.replacement];
|
||||
patch.replacement = patch.replacement.map(v => {
|
||||
return {
|
||||
match: String(v.match),
|
||||
replace: String(v.replace)
|
||||
};
|
||||
const toSend = JSON.stringify(reporterData, (_k, v) => {
|
||||
if (v instanceof RegExp)
|
||||
return String(v);
|
||||
return v;
|
||||
});
|
||||
}
|
||||
}
|
||||
replyData({
|
||||
|
||||
socket?.send(JSON.stringify({
|
||||
type: "report",
|
||||
data: toSend,
|
||||
data: JSON.parse(toSend),
|
||||
ok: true
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue