From cf4193c3522254e675766ea94027220166310da8 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 18 Dec 2024 10:43:07 +0800 Subject: [PATCH] chore: Add cleanup for existing Merico workflow directory - Add safety check to remove existing workflow directory if present - Ensure clean installation by removing old files before copying - Prevent potential conflicts during version updates --- src/contributes/commands.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 2dc2085..1f6788d 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -219,6 +219,9 @@ export function registerInstallCommandsCommand( let copiedDirectory = false; if (!fs.existsSync(sysMericoDirPath) || (updatePublicWorkflow === false && currentVersion !== previousVersion)) { logger.channel()?.debug("Creating directory: " + sysMericoDirPath); + if (fs.existsSync(sysMericoDirPath)) { + fs.rmSync(sysMericoDirPath, { recursive: true, force: true }); + } await copyDirectory(pluginDirPath, sysDirPath); copiedDirectory = true; }