-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathclear-cache.command.ts
More file actions
40 lines (30 loc) · 1.18 KB
/
clear-cache.command.ts
File metadata and controls
40 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import fs from 'node:fs/promises';
import kleur from 'kleur';
import _ from 'lodash-es';
import { outdent } from 'outdent';
import { DmnoCommand } from '../lib/dmno-command';
import { getCliRunCtx } from '../lib/cli-ctx';
import { pathExists } from '../../config-loader/find-services';
const program = new DmnoCommand('clear-cache')
.summary('cache utils')
.description(outdent`
Tools to clear / reset the cache
Also note many commands have \`--skip-cache\` and \`--clear-cache\` flags
`)
.example('dmno clear-cache', 'Clear the entire cache');
// .example('dmno cache clear -s web', 'Clear items from the cache used by the "web" service only');
// addServiceSelection(program);
program.action(async (opts, more) => {
const ctx = getCliRunCtx();
const workspace = await ctx.configLoader.getWorkspace();
if (!await pathExists(workspace.cacheFilePath)) {
console.log('👻 Workspace cache file already gone!\n');
process.exit(0);
}
await fs.rm(workspace.cacheFilePath);
console.log('🧲💾 Workspace cache file erased');
console.log(kleur.italic().gray(workspace.cacheFilePath));
console.log();
process.exit(0);
});
export const ClearCacheCommand = program;