Skip to content

Commit

Permalink
fix cache folder option
Browse files Browse the repository at this point in the history
  • Loading branch information
georges-gomes committed Oct 4, 2023
1 parent e12beef commit 0ae1ed5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import { CACHE_VERSIONS } from './packagejson.js';

const listOfCategories = ['img', 'img-ext'] as const;

const CACHE_FOLDER = $state.args.cache_folder || '.jampack/cache';

export type Category = (typeof listOfCategories)[number];

export type CacheData = { buffer: Buffer; meta: any };

function getCacheFolder(): string {
return $state.args.cache_folder || '.jampack/cache';
}

async function cleanCache(full: boolean) {
const CACHE_FOLDER = getCacheFolder();

if (full) {
try {
await fs.rm(CACHE_FOLDER, { recursive: true });
Expand Down Expand Up @@ -72,6 +76,8 @@ function getVersionOfCategory(category: Category): string {
}

function getLocation(hash: string, category: Category): string {
const CACHE_FOLDER = getCacheFolder();

return path.join(
CACHE_FOLDER,
category,
Expand Down

0 comments on commit 0ae1ed5

Please sign in to comment.