Files
rea/tests/support/cli/childHome.ts
T
gensokyo-devandgensokyo-dev 6e5b6f1ede test: give CLI and MCP test children an owned home
A test child given no home resolved the account's real home and read its
saved REA configuration. cliTest's shared worker, its fresh processes, its
file MCP session and direct connectLocalToolsMcp() connections all did so.

cliTest now owns one home per file, and a direct MCP connection owns one per
connection, removed only after its server closes. A caller that selects
HOME, USERPROFILE, HOMEDRIVE or HOMEPATH, even as an empty value, keeps its
whole selection.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00

27 lines
790 B
TypeScript

/**
* A test-owned home for a child process. Without one, a child resolves the
* account's real home and reads its saved REA configuration.
*/
export const childHomeEnvironment = (home: string): Record<string, string> => ({
HOME: home,
USERPROFILE: home,
});
/** Variables a child reads to find its home. */
const HOME_SELECTION_VARIABLES = [
"HOME",
"USERPROFILE",
"HOMEDRIVE",
"HOMEPATH",
] as const;
/**
* Whether the caller's environment selects the child's home itself. A caller
* that sets any of these keeps all of them, even an empty value.
*/
export const selectsChildHome = (
environment: Readonly<Record<string, unknown>> | undefined,
): boolean =>
environment !== undefined &&
HOME_SELECTION_VARIABLES.some((name) => Object.hasOwn(environment, name));