From 064acfd9532218220b71e99cbf570988b4d67dd5 Mon Sep 17 00:00:00 2001 From: goerlibe <23436477+goerlibe@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:43:00 +0100 Subject: [PATCH] fix: hotspot detection uses correct build directories --- .../HotspotDetectionRunner.ts | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/HotspotDetection/HotspotDetectionRunner.ts b/src/HotspotDetection/HotspotDetectionRunner.ts index 8eff82b..3b9e2d8 100644 --- a/src/HotspotDetection/HotspotDetectionRunner.ts +++ b/src/HotspotDetection/HotspotDetectionRunner.ts @@ -40,20 +40,25 @@ export abstract class HotspotDetectionRunner { message: 'Preparing build directory...', increment: 5, operation: async () => { - if (fs.existsSync(args.buildPath)) { - // remove everything but the .discopop directory from the build directory - const files = fs.readdirSync(args.buildPath) - for (const file of files) { - if (file !== '.discopop') { - fs.rmSync(`${args.buildPath}/${file}`, { - recursive: true, - }) - } - } + if (!fs.existsSync(args.buildPath)) { + fs.mkdirSync(args.buildPath, { + recursive: true, + }) + } else if ( + Config.skipOverwriteConfirmation() || + (await UIPrompts.actionConfirmed( + 'The build directory already exists. Do you want to overwrite it?\n(You can disable this dialog in the extension settings)' + )) + ) { + fs.rmSync(args.buildPath, { + recursive: true, + }) + fs.mkdirSync(args.buildPath, { + recursive: true, + }) + } else { + throw new Error('Operation cancelled by user') } - fs.mkdirSync(args.buildPath, { - recursive: true, - }) }, })