Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@142vip/fairy-cli): clean命令增加--coverage参数,支持单元测试目录清理 #311

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading