-
Notifications
You must be signed in to change notification settings - Fork 10
/
clear.action.ts
42 lines (33 loc) 路 923 Bytes
/
clear.action.ts
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
41
42
/*
* @Author: Cphayim
* @Date: 2022-05-16 11:25:16
* @Description: boilerplate clear command action
*/
import fs from 'fs-extra'
import { Action, type ActionArgs } from '@vrn-deco/cli-command'
import { logger } from '@vrn-deco/cli-log'
import { getCacheDirectory } from '../utils.js'
type ClearArguments = []
type ClearOptions = {
//
}
export type ClearActionArgs = ActionArgs<ClearArguments, ClearOptions>
export class ClearAction extends Action<ClearArguments, ClearOptions> {
cacheDir = getCacheDirectory()
async initialize(): Promise<void> {
//
}
async execute(): Promise<void> {
await this.clearCache()
logger.done('Successfully cleared boilerplate package dependency cache.')
}
async clear(): Promise<void> {
//
}
async clearCache() {
if (fs.existsSync(this.cacheDir)) {
logger.verbose(`clear ${this.cacheDir}}`)
fs.removeSync(this.cacheDir)
}
}
}