mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-13 05:52:03 +00:00
- Remove CurrencyPicker component and all related state from dashboard - Promote 'codeburn config currency' to top-level 'codeburn currency' - Strip JSDoc comments that explain WHAT not WHY - Remove forceRender hack and unused imports
36 lines
863 B
TypeScript
36 lines
863 B
TypeScript
import { readFile, writeFile, mkdir } from 'fs/promises'
|
|
import { join } from 'path'
|
|
import { homedir } from 'os'
|
|
|
|
export type CodeburnConfig = {
|
|
currency?: {
|
|
code: string
|
|
symbol?: string
|
|
}
|
|
}
|
|
|
|
function getConfigDir(): string {
|
|
return join(homedir(), '.config', 'codeburn')
|
|
}
|
|
|
|
function getConfigPath(): string {
|
|
return join(getConfigDir(), 'config.json')
|
|
}
|
|
|
|
export async function readConfig(): Promise<CodeburnConfig> {
|
|
try {
|
|
const raw = await readFile(getConfigPath(), 'utf-8')
|
|
return JSON.parse(raw) as CodeburnConfig
|
|
} catch {
|
|
return {}
|
|
}
|
|
}
|
|
|
|
export async function saveConfig(config: CodeburnConfig): Promise<void> {
|
|
await mkdir(getConfigDir(), { recursive: true })
|
|
await writeFile(getConfigPath(), JSON.stringify(config, null, 2) + '\n', 'utf-8')
|
|
}
|
|
|
|
export function getConfigFilePath(): string {
|
|
return getConfigPath()
|
|
}
|