mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 14:22:27 +00:00
Replace env-paths with xdg-basedir for better XDG compliance and cross-platform directory handling
🤖 Generated with opencode Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
import envpaths from "env-paths"
|
||||
import fs from "fs/promises"
|
||||
const paths = envpaths("opencode", {
|
||||
suffix: "",
|
||||
})
|
||||
import { xdgData, xdgCache, xdgConfig } from "xdg-basedir"
|
||||
import path from "path"
|
||||
|
||||
const app = "opencode"
|
||||
|
||||
const data = path.join(xdgData!, app)
|
||||
const cache = path.join(xdgCache!, app)
|
||||
const config = path.join(xdgConfig!, app)
|
||||
|
||||
await Promise.all([
|
||||
fs.mkdir(paths.config, { recursive: true }),
|
||||
fs.mkdir(paths.cache, { recursive: true }),
|
||||
fs.mkdir(data, { recursive: true }),
|
||||
fs.mkdir(config, { recursive: true }),
|
||||
fs.mkdir(cache, { recursive: true }),
|
||||
])
|
||||
|
||||
export namespace Global {
|
||||
export function config() {
|
||||
return paths.config
|
||||
}
|
||||
|
||||
export function cache() {
|
||||
return paths.cache
|
||||
}
|
||||
|
||||
export function data() {
|
||||
return paths.data
|
||||
}
|
||||
export const Path = {
|
||||
data,
|
||||
cache,
|
||||
config,
|
||||
} as const
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user