Files

23 lines
774 B
TypeScript

import { join } from "node:path";
import { childHomeEnvironment } from "../../support/cli/childHome.js";
import type { TestCli } from "../../support/cli/cliFixture.js";
/** Run setup, doctor or uninstall against one test-owned home. */
export const setupCliInHome =
(cli: TestCli, home: string, config?: "claude" | "xdg" | "claude-and-xdg") =>
(arguments_: readonly string[]) =>
cli.run({
arguments: arguments_,
cwd: home,
environment: {
...childHomeEnvironment(home),
...(config === "claude" || config === "claude-and-xdg"
? { CLAUDE_CONFIG_DIR: home }
: {}),
...(config === "xdg" || config === "claude-and-xdg"
? { XDG_CONFIG_HOME: join(home, ".config") }
: {}),
},
});