Skip to content

Commit

Permalink
feat(@142vip/fairy-cli): clean命令增加--coverage参数,支持单元测试目录清理
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdapl committed Jan 19, 2025
1 parent 311a0f2 commit 81a46ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/fairy-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ Options:
--turbo 删除turbo缓存目录 (default: false)
--vite 删除vite缓存目录 (default: false)
--deps 删除node_modules目录 (default: false)
--coverage 删除coverage目录 (default: false)
-f,--force 强制删除,默认值:false (default: false)
--all 深度删除所有 (default: false)
--ignore-tips 忽略提示,直接删除 (default: false)
--dry-run 试运行,不做实际删除操作 (default: false)
-h, --help display help for command

```

#### 使用示例
Expand Down
7 changes: 7 additions & 0 deletions packages/fairy-cli/src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface CleanUpOptions extends DelOptions {
turbo?: boolean
vite?: boolean
deps?: boolean
coverage?: boolean
}

/**
Expand Down Expand Up @@ -60,6 +61,11 @@ async function execCleanUp(args: CleanUpOptions) {
dirPatterns.push(...generateDirPatterns('.vite', args.all))
}

// 删除单元测试目录
if (args.coverage) {
dirPatterns.push(...generateDirPatterns('coverage', args.all))
}

if (dirPatterns.length === 0) {
console.log('删除规则为空,不做删除操作处理,请传入有效参数!!')
process.exit(1)
Expand Down Expand Up @@ -122,6 +128,7 @@ export async function cleanUpMain(program: VipCommander) {
.option('--turbo', '删除turbo缓存目录', false)
.option('--vite', '删除vite缓存目录', false)
.option('--deps', '删除node_modules目录', false)
.option('--coverage', '删除coverage目录', false)
.option('-f,--force', '强制删除,默认值:false', false)
.option('--all', '深度删除所有', false)
.option('--ignore-tips', '忽略提示,直接删除', false)
Expand Down

0 comments on commit 81a46ff

Please sign in to comment.