fix(shared): add additive opencode config directory discovery
This commit is contained in:
@@ -55,16 +55,37 @@ function resolveConfigPath(pathValue: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
function getCliConfigDir(): string {
|
||||
const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim()
|
||||
if (envConfigDir) {
|
||||
return resolveConfigPath(envConfigDir)
|
||||
}
|
||||
|
||||
function getCliDefaultConfigDir(): string {
|
||||
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config")
|
||||
return resolveConfigPath(join(xdgConfig, "opencode"))
|
||||
}
|
||||
|
||||
function getCliCustomConfigDir(): string | null {
|
||||
const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim()
|
||||
if (!envConfigDir) {
|
||||
return null
|
||||
}
|
||||
|
||||
return resolveConfigPath(envConfigDir)
|
||||
}
|
||||
|
||||
function getCliConfigDir(): string {
|
||||
return getCliCustomConfigDir() ?? getCliDefaultConfigDir()
|
||||
}
|
||||
|
||||
export function getOpenCodeConfigDirs(options: OpenCodeConfigDirOptions): string[] {
|
||||
if (options.binary !== "opencode") {
|
||||
return [getOpenCodeConfigDir(options)]
|
||||
}
|
||||
|
||||
return Array.from(
|
||||
new Set([
|
||||
...(getCliCustomConfigDir() ? [getCliCustomConfigDir()!] : []),
|
||||
getCliDefaultConfigDir(),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
export function getOpenCodeConfigDir(options: OpenCodeConfigDirOptions): string {
|
||||
const { binary, version, checkExisting = true } = options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user