mirror of
https://github.com/przeprogramowani/10x-cli.git
synced 2026-09-19 03:30:01 +08:00
a0832349f0
On Windows, configDir() reads APPDATA, not XDG_CONFIG_HOME. Tests that only redirected XDG_CONFIG_HOME leaked config state across test files, causing failures on windows-latest CI. Extract redirectConfigDir/ restoreConfigDir helper that sets both env vars, apply across all 10 test files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
789 B
TypeScript
24 lines
789 B
TypeScript
/**
|
|
* Cross-platform config directory isolation for tests.
|
|
*
|
|
* On POSIX, configDir() reads XDG_CONFIG_HOME. On Windows, it reads APPDATA.
|
|
* Tests must redirect both to a temp directory for proper isolation.
|
|
*/
|
|
|
|
let priorXdg: string | undefined;
|
|
let priorAppData: string | undefined;
|
|
|
|
export function redirectConfigDir(tmpDir: string): void {
|
|
priorXdg = process.env["XDG_CONFIG_HOME"];
|
|
priorAppData = process.env["APPDATA"];
|
|
process.env["XDG_CONFIG_HOME"] = tmpDir;
|
|
process.env["APPDATA"] = tmpDir;
|
|
}
|
|
|
|
export function restoreConfigDir(): void {
|
|
if (priorXdg === undefined) delete process.env["XDG_CONFIG_HOME"];
|
|
else process.env["XDG_CONFIG_HOME"] = priorXdg;
|
|
if (priorAppData === undefined) delete process.env["APPDATA"];
|
|
else process.env["APPDATA"] = priorAppData;
|
|
}
|