fix(test): address review follow-ups for config dir layering

This commit is contained in:
jollyxenon
2026-05-09 00:51:37 +08:00
parent 8d5dd908b8
commit 66a1a9ad1d
2 changed files with 9 additions and 1 deletions
@@ -56,6 +56,7 @@ const NO_FRONTMATTER_AGENT = `Just a prompt with no frontmatter.`;
describe("claude-code-agent-loader", () => { describe("claude-code-agent-loader", () => {
const dirs: string[] = []; const dirs: string[] = [];
const originalEnv = { const originalEnv = {
CLAUDE_CONFIG_DIR: process.env.CLAUDE_CONFIG_DIR,
OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR, OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR,
XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME, XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME,
} }
@@ -65,6 +66,11 @@ describe("claude-code-agent-loader", () => {
rmSync(dir, { recursive: true, force: true }); rmSync(dir, { recursive: true, force: true });
} }
dirs.length = 0; dirs.length = 0;
if (originalEnv.CLAUDE_CONFIG_DIR === undefined) {
delete process.env.CLAUDE_CONFIG_DIR
} else {
process.env.CLAUDE_CONFIG_DIR = originalEnv.CLAUDE_CONFIG_DIR
}
if (originalEnv.OPENCODE_CONFIG_DIR === undefined) { if (originalEnv.OPENCODE_CONFIG_DIR === undefined) {
delete process.env.OPENCODE_CONFIG_DIR delete process.env.OPENCODE_CONFIG_DIR
} else { } else {
+3 -1
View File
@@ -78,9 +78,11 @@ export function getOpenCodeConfigDirs(options: OpenCodeConfigDirOptions): string
return [getOpenCodeConfigDir(options)] return [getOpenCodeConfigDir(options)]
} }
const customConfigDir = getCliCustomConfigDir()
return Array.from( return Array.from(
new Set([ new Set([
...(getCliCustomConfigDir() ? [getCliCustomConfigDir()!] : []), ...(customConfigDir ? [customConfigDir] : []),
getCliDefaultConfigDir(), getCliDefaultConfigDir(),
]), ]),
) )