fix(installer): always use .config/opencode for CLI on Windows (#2502)
This commit is contained in:
@@ -191,6 +191,20 @@ describe("opencode-config-dir", () => {
|
||||
// then returns ~/.config/opencode (cross-platform default)
|
||||
expect(result).toBe(join(homedir(), ".config", "opencode"))
|
||||
})
|
||||
|
||||
test("returns ~/.config/opencode on Windows even when APPDATA is set (#2502)", () => {
|
||||
// given opencode CLI binary detected, platform is Windows with APPDATA set
|
||||
// (regression test: previously would check AppData for existing config)
|
||||
Object.defineProperty(process, "platform", { value: "win32" })
|
||||
process.env.APPDATA = "C:\\Users\\TestUser\\AppData\\Roaming"
|
||||
delete process.env.OPENCODE_CONFIG_DIR
|
||||
|
||||
// when getOpenCodeConfigDir is called with binary="opencode"
|
||||
const result = getOpenCodeConfigDir({ binary: "opencode", version: "1.0.200", checkExisting: false })
|
||||
|
||||
// then returns ~/.config/opencode (ignores APPDATA entirely for CLI)
|
||||
expect(result).toBe(join(homedir(), ".config", "opencode"))
|
||||
})
|
||||
})
|
||||
|
||||
describe("for opencode-desktop Tauri binary", () => {
|
||||
|
||||
@@ -49,22 +49,7 @@ function getCliConfigDir(): string {
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
const crossPlatformDir = join(homedir(), ".config", "opencode")
|
||||
const crossPlatformConfig = join(crossPlatformDir, "opencode.json")
|
||||
|
||||
if (existsSync(crossPlatformConfig)) {
|
||||
return crossPlatformDir
|
||||
}
|
||||
|
||||
const appData = process.env.APPDATA || join(homedir(), "AppData", "Roaming")
|
||||
const appdataDir = join(appData, "opencode")
|
||||
const appdataConfig = join(appdataDir, "opencode.json")
|
||||
|
||||
if (existsSync(appdataConfig)) {
|
||||
return appdataDir
|
||||
}
|
||||
|
||||
return crossPlatformDir
|
||||
return join(homedir(), ".config", "opencode")
|
||||
}
|
||||
|
||||
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config")
|
||||
|
||||
Reference in New Issue
Block a user