From 5339de67a7f825a250dd81f08d5e86738a02315e Mon Sep 17 00:00:00 2001 From: rasheed Date: Wed, 17 Apr 2024 23:58:26 +0100 Subject: [PATCH] Refactor directory checks into a separate function to clean up the download function --- extra/download-dist.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/extra/download-dist.js b/extra/download-dist.js index 12b0cb07..fa7912d2 100644 --- a/extra/download-dist.js +++ b/extra/download-dist.js @@ -26,15 +26,14 @@ function download(url) { if (response.statusCode === 200) { console.log("Extracting dist..."); - if (fs.existsSync("./dist")) { - - if (fs.existsSync("./dist-backup")) { - rmSync("./dist-backup", { - recursive: true - }); - } - - fs.renameSync("./dist", "./dist-backup"); +function handleDirectoryCleanup() { + if (fs.existsSync("./dist")) { + if (fs.existsSync("./dist-backup")) { + rmSync("./dist-backup", { recursive: true }); + } + fs.renameSync("./dist", "./dist-backup"); + } +} } const tarStream = tar.x({