Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/bin/fake-claude.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env node
// Fake `claude` binary for adapter tests: prints a fixture stream and
// behaves according to the FAKE_* environment variables.
import { readFileSync, writeFileSync } from "node:fs";
import { readFileSync, renameSync, writeFileSync } from "node:fs";

if (process.env.FAKE_ARGS_OUT) {
// write then rename: a test that polls for the file and kills this process
// must never read it half-written
const tmp = `${process.env.FAKE_ARGS_OUT}.${process.pid}.tmp`;
writeFileSync(
process.env.FAKE_ARGS_OUT,
tmp,
JSON.stringify({
args: process.argv.slice(2),
cwd: process.cwd(),
claudeProjectDir: process.env.CLAUDE_PROJECT_DIR ?? null,
claudeConfigDir: process.env.CLAUDE_CONFIG_DIR ?? null,
}),
);
renameSync(tmp, process.env.FAKE_ARGS_OUT);
}

if (process.env.FAKE_STDERR) process.stderr.write(process.env.FAKE_STDERR);
Expand Down
Loading