@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 38 lines 1.23 KB
Raw
1 import { expect, it } from "@alchemy.run/test";
2 import * as BunServices from "@effect/platform-bun/BunServices";
3 import * as Effect from "effect/Effect";
4 import * as FileSystem from "effect/FileSystem";
5 import * as Path from "effect/Path";
6 import { makeFileLog } from "../src/FileLog.ts";
7
8 it.live("preserves stray output appended between captured log writes", () =>
9 Effect.gen(function* () {
10 const fs = yield* FileSystem.FileSystem;
11 const path = yield* Path.Path;
12 const root = yield* fs.makeTempDirectoryScoped({
13 prefix: "alchemy-file-log-",
14 });
15 const file = path.join(root, "run.log");
16 const log = yield* makeFileLog(file);
17 yield* Effect.sync(() =>
18 log.appendHookLine("file", {
19 level: "info",
20 message: "before",
21 time: new Date(0),
22 }),
23 );
24 yield* fs.writeFileString(file, "stray-output\n", { flag: "a" });
25 yield* Effect.sync(() =>
26 log.appendTestLine("test", {
27 level: "info",
28 message: "after",
29 time: new Date(0),
30 }),
31 );
32 yield* log.close;
33 yield* log.close;
34 expect(yield* fs.readFileString(file)).toBe(
35 "[hook file] before\nstray-output\n[test test] after\n",
36 );
37 }).pipe(Effect.provide(BunServices.layer)),
38 );