From 8019578e0ef6b4b3411f54a0df825048425d7e38 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 27 Jan 2024 20:08:31 +0100 Subject: [PATCH] enhance: dont delete dir if it is cwd --- src/bundle.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bundle.ts b/src/bundle.ts index e47eb2f0..62d1397d 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -123,7 +123,7 @@ async function bundle( ): Promise => { if (options.clean) { if (!isFromCli) { - await removeOutputDir(rollupConfig.output) + await removeOutputDir(rollupConfig.output, cwd) } } @@ -271,8 +271,9 @@ function logWatcherBuildTime(result: RollupWatcher[]) { }) } -async function removeOutputDir(output: OutputOptions) { - if (output.dir) await removeDir(output.dir) +async function removeOutputDir(output: OutputOptions, cwd: string) { + const dir = output.dir + if (dir && dir !== cwd) await removeDir(dir) } function runBundle({ input, output }: BuncheeRollupConfig) {