MCPcopy Create free account
hub / github.com/cortexkit/magic-context / appendLine

Function appendLine

packages/plugin/scripts/longmemeval/runner.ts:74–91  ·  view source on GitHub ↗
(filePath: string, line: string)

Source from the content-addressed store, hash-verified

72}
73
74async function appendLine(filePath: string, line: string): Promise<void> {
75 await enqueueWrite(async () => {
76 await ensureParentDirectory(filePath);
77 let current = "";
78 try {
79 current = await readFile(filePath, "utf8");
80 } catch (error) {
81 const typed = asError(error);
82 if ((typed as NodeJS.ErrnoException).code !== "ENOENT") {
83 throw typed;
84 }
85 }
86
87 const tempPath = `${filePath}.${crypto.randomUUID()}.tmp`;
88 await writeFile(tempPath, `${current}${line}\n`, "utf8");
89 await rename(tempPath, filePath);
90 });
91}
92
93async function appendLog(filePath: string, line: string): Promise<void> {
94 await appendLine(filePath, `[${new Date().toISOString()}] ${line}`);

Callers 2

appendLogFunction · 0.85
judgeQuestionFunction · 0.85

Calls 3

enqueueWriteFunction · 0.85
ensureParentDirectoryFunction · 0.85
asErrorFunction · 0.70

Tested by

no test coverage detected