Spaces:
Runtime error
Runtime error
File size: 1,148 Bytes
8bf5d01 01d948e 8bf5d01 2a70ee5 8bf5d01 01d948e 8bf5d01 01d948e 8bf5d01 01d948e 8bf5d01 01d948e 8bf5d01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import fs from "fs/promises";
import path from "path";
import { PoCState } from "../state.js";
import { logger } from "../../../logger.js";
export async function contextNode(state: PoCState): Promise<Partial<PoCState>> {
logger.info(`[Tester] contextNode: Preparando ambiente de testes para: ${state.report.title}`);
if (state.report.customSandboxDir) {
try {
const testDir = path.join(state.report.customSandboxDir, "test");
const testEntries = await fs.readdir(testDir, { withFileTypes: true }).catch(() => []);
let removed = 0;
for (const entry of testEntries) {
if (entry.isFile() && entry.name.endsWith(".t.sol") && entry.name !== "Exploit.t.sol") {
await fs.unlink(path.join(testDir, entry.name));
removed++;
}
}
if (removed > 0) {
logger.info(`[Tester] contextNode: Limpos ${removed} arquivos de teste antigos.`);
}
} catch (e) {
logger.warn(`[Tester] contextNode: falha na limpeza do diretório de testes: ${(e as Error).message}`);
}
}
return {
templateCode: "",
pocCode: "",
infrastructurePhase: false,
};
}
|