Skip to content

Commit

Permalink
cache folder configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
georges-gomes committed Oct 3, 2023
1 parent 63b09e1 commit e12beef
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@divriots/jampack",
"version": "0.20.2",
"version": "0.21.0",
"cache-version": {
"img": "v1",
"img-ext": "v1"
Expand Down
1 change: 1 addition & 0 deletions packages/www/src/pages/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ layout: ../layouts/MainLayout.astro
| `--exclude` | Files to exclude from processing. Expect glob format like `--exclude 'blog/**'` |
| `--cleancache`| Clean cache before running |
| `--nocache` | Don't use the cache (no read or write to cache) |
| `--cache_folder` | followed by the cache folder location. By default '.jampack/cache' |
5 changes: 3 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import $state from './state.js';
import { CACHE_VERSIONS } from './packagejson.js';

const listOfCategories = ['img', 'img-ext'] as const;
export type Category = (typeof listOfCategories)[number];

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

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

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

Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ program
.option('--fail', 'Exits with a non-zero return code if issues.')
.option('--onlyoptim', 'Only optimize (PASS 1).')
.option('--onlycomp', 'Only compress (PASS 2).')
.option('--cache_folder <cache_folder>', 'Default: .jampack/cache')
.option('--cleancache', 'Clean cache before running')
.option('--nocache', 'Run with no use of cache')
.action(async (dir, options) => {
// Arguments
$state.dir = dir;
$state.args = options;

// Print options
if (options) {
console.log('Options:');
console.log(options);
Expand Down
1 change: 1 addition & 0 deletions src/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type Args = {
nowrite?: boolean;
nocache?: boolean;
cache_folder?: string;
};

export type ReportItem = {
Expand Down

0 comments on commit e12beef

Please sign in to comment.