From 7ba7be920a9dacf39509922bbc6d1d79a5dfc3e8 Mon Sep 17 00:00:00 2001 From: chufan Date: Wed, 17 Jul 2024 21:16:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(@142vip/fairy-cli):=20=E6=94=AF=E6=8C=81tu?= =?UTF-8?q?rbo=E5=8F=AF=E9=80=89=E5=8F=82=E6=95=B0=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4turbo=E6=9E=84=E5=BB=BA=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fairy-cli/src/core/clean.ts | 11 +++++++++-- packages/fairy-cli/src/fairy-cli.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/fairy-cli/src/core/clean.ts b/packages/fairy-cli/src/core/clean.ts index 76bb6bc..f50f616 100644 --- a/packages/fairy-cli/src/core/clean.ts +++ b/packages/fairy-cli/src/core/clean.ts @@ -16,6 +16,7 @@ export interface CleanUpOptions extends DelOptions { nuxt?: boolean midway?: boolean ignoreTips?: boolean + turbo?: boolean } /** @@ -41,6 +42,11 @@ export async function execCleanUp(args: CleanUpOptions) { dirPatterns.push(...generateDirPatterns(['run', 'logs'], args.all)) } + // 删除turbo缓存目录 + if (args.turbo) { + dirPatterns.push(...generateDirPatterns('.turbo', args.all)) + } + // 删除前,对话框确认 if (!args.ignoreTips) { const deleted = await confirm({ @@ -61,6 +67,7 @@ export async function execCleanUp(args: CleanUpOptions) { const deletedDirs = await deleteAsync(dirPatterns, { dryRun: args.dryRun, force: args.force, + dot: true, }) console.log(deletedDirs) } @@ -77,11 +84,11 @@ function generateDirPatterns(dirName: string | string[], delAll?: boolean) { if (delAll) { // 删除程序上下文中所有的该目录 - delDirs = delDirs.map(dir => `**/${dir}/*`) + delDirs = delDirs.map(dir => `**/${dir}`) } else { // 只删除该目录 - delDirs = delDirs.map(dir => `${dir}/*`) + delDirs = delDirs.map(dir => `${dir}`) } return delDirs diff --git a/packages/fairy-cli/src/fairy-cli.ts b/packages/fairy-cli/src/fairy-cli.ts index 5c1fe54..3c665dd 100644 --- a/packages/fairy-cli/src/fairy-cli.ts +++ b/packages/fairy-cli/src/fairy-cli.ts @@ -151,6 +151,7 @@ program .option('--all', '深度删除所有', false) .option('--ignore-tips', '忽略提示,直接删除', false) .option('--dry-run', '试运行,不做实际删除操作', false) + .option('--turbo', '删除turbo缓存目录', true) .action(async (args: CleanUpOptions) => { await execCleanUp(args) })