From 573ef495777395db2346530f8231a16542e5801e Mon Sep 17 00:00:00 2001 From: bgenia Date: Wed, 29 Nov 2023 05:41:24 +0300 Subject: [PATCH] feat: export local & global cache directories --- src/cache/cache.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cache/cache.ts b/src/cache/cache.ts index dd979b4..58c7799 100644 --- a/src/cache/cache.ts +++ b/src/cache/cache.ts @@ -23,9 +23,14 @@ const cacheOptions = { const AUTH_TTL_SEX = 60 * 60 * 10 // 10h const PERSISTENT_TTL_SEX = 60 * 60 * 48 // 48h -const cacheDirBase = cacheOptions.local ? process.cwd() : homedir() +const CACHE_BASENAME = ".s21/cache" -export const cacheDirectory = resolve(cacheDirBase, ".s21/cache") +export const globalCacheDirectory = resolve(homedir(), CACHE_BASENAME) +export const localCacheDirectory = resolve(process.cwd(), CACHE_BASENAME) + +export const cacheDirectory = cacheOptions.local + ? localCacheDirectory + : globalCacheDirectory await mkdir(cacheDirectory, { recursive: true,