- Document platform-specific config paths in README (en/ko/ja) - Windows: %APPDATA%\opencode\oh-my-opencode.json - macOS/Linux: ~/.config/opencode/oh-my-opencode.json - Show config file path in startup toast - Add config load error warnings when JSON parsing or validation fails - Extract getUserConfigDir to shared/config-path.ts for reuse Fixes #97 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
30
src/shared/config-path.ts
Normal file
30
src/shared/config-path.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as path from "path"
|
||||
import * as os from "os"
|
||||
|
||||
/**
|
||||
* Returns the user-level config directory based on the OS.
|
||||
* - Linux/macOS: XDG_CONFIG_HOME or ~/.config
|
||||
* - Windows: %APPDATA%
|
||||
*/
|
||||
export function getUserConfigDir(): string {
|
||||
if (process.platform === "win32") {
|
||||
return process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming")
|
||||
}
|
||||
|
||||
// Linux, macOS, and other Unix-like systems: respect XDG_CONFIG_HOME
|
||||
return process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config")
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full path to the user-level oh-my-opencode config file.
|
||||
*/
|
||||
export function getUserConfigPath(): string {
|
||||
return path.join(getUserConfigDir(), "opencode", "oh-my-opencode.json")
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full path to the project-level oh-my-opencode config file.
|
||||
*/
|
||||
export function getProjectConfigPath(directory: string): string {
|
||||
return path.join(directory, ".opencode", "oh-my-opencode.json")
|
||||
}
|
||||
@@ -10,3 +10,4 @@ export * from "./hook-disabled"
|
||||
export * from "./deep-merge"
|
||||
export * from "./file-utils"
|
||||
export * from "./dynamic-truncator"
|
||||
export * from "./config-path"
|
||||
|
||||
Reference in New Issue
Block a user