Skip to content

Commit f4a3eb0

Browse files
committed
feat: update cache path
1 parent 2c9dbee commit f4a3eb0

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/config/paths.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os from "node:os"
22
import path from "pathe"
33

4-
const DIR_CACHE = path.join(os.homedir(), ".cache", "copilot-api")
4+
const APP_DIR = path.join(os.homedir(), ".local", "share", "copilot-api")
55

6-
const PATH_CACHE_FILE = path.join(DIR_CACHE, "cache.json")
6+
const CACHE_PATH = path.join(APP_DIR, "cache.json")
77

88
export const PATHS = {
9-
DIR_CACHE,
10-
PATH_CACHE_FILE,
9+
APP_DIR,
10+
CACHE_PATH,
1111
}

src/lib/cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ interface CacheEntry {
88
type Cache = Record<string, CacheEntry>
99

1010
const readCache = async () => {
11-
const content = await Bun.file(PATHS.PATH_CACHE_FILE).text()
11+
const content = await Bun.file(PATHS.CACHE_PATH).text()
1212
return JSON.parse(content) as Cache
1313
}
1414

1515
const writeCache = (cache: Cache) =>
16-
Bun.write(PATHS.PATH_CACHE_FILE, JSON.stringify(cache))
16+
Bun.write(PATHS.CACHE_PATH, JSON.stringify(cache))
1717

1818
const setCache = async (key: string, value: string) => {
1919
const cache = await readCache()

src/lib/initialization.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const initSteps: Array<InitStep> = [
3131
{
3232
name: "Cache",
3333
run: async () => {
34-
if (!fs.existsSync(PATHS.PATH_CACHE_FILE)) {
35-
fs.mkdirSync(PATHS.DIR_CACHE, { recursive: true })
34+
if (!fs.existsSync(PATHS.CACHE_PATH)) {
35+
fs.mkdirSync(PATHS.APP_DIR, { recursive: true })
3636
await CACHE._write({})
3737
}
3838
},

0 commit comments

Comments
 (0)