Skip to content
11 linesCodeBlameRaw
1#!/usr/bin/env node
2// A stand-in for the g1t CLI in the hook tests: writes each call to
3// FAKE_G1T_LOG as a JSON line and answers as FAKE_G1T_* say.
4import { appendFileSync } from "node:fs";
5
6const args = process.argv.slice(2);
7appendFileSync(process.env.FAKE_G1T_LOG, `${JSON.stringify({ args, session: process.env.G1T_SESSION ?? null })}\n`);
8const exit = Number(process.env.FAKE_G1T_EXIT ?? 0);
9if (exit) process.exit(exit);
10if (args[0] === "session" && args[1] === "start") process.stdout.write(JSON.stringify({ id: "ses_fake01", state: "active" }));
11if (args[0] === "work" && args[1] === "context") process.stdout.write(`#${args[2]} The issue's title\nDefinition of done: it works.\n`);