From 3e5e0c56cfa98b56562b3ae4dd1931f6819433cc Mon Sep 17 00:00:00 2001 From: X3F200C Date: Mon, 7 Aug 2023 20:21:46 -0400 Subject: [PATCH] Fix launcher not opening if no files have to be downloaded and add more info to package.json --- index.js | 54 +++++++++++++++++++++++++++++----------------------- package.json | 3 ++- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index ebe28e6..b5c5125 100644 --- a/index.js +++ b/index.js @@ -153,7 +153,7 @@ async function checkFiles() { var filePath = path.join(basePath, ...(file.name.split("/"))); if (!fs.existsSync(filePath)) { - console.log("File " + file.name + " needs to be downloaded. "); + console.log("\x1b[32mFile " + file.name + " needs to be downloaded.\x1b[0m"); filesToDownload.push(file); continue; } @@ -161,10 +161,10 @@ async function checkFiles() { var sum = await getFileSHA1(filePath); if (sum !== file.hash) { - console.log("File " + file.name + " needs to be downloaded again. "); + console.log("\x1b[33mFile " + file.name + " needs to be updated.\x1b[0m"); filesToDownload.push(file); } else { - console.log("File " + file.name + " doesn't need to be downloaded again. "); + // console.log("File " + file.name + " doesn't need to be downloaded again. "); } } @@ -176,14 +176,16 @@ async function downloadFiles(files) { var file = files[f]; var filePath = path.join(basePath, ...(file.name.split("/"))); - console.log("Downloading file " + file.name + "... "); + console.log("Downloading file " + file.name + "..."); await httpsDownload(file.baseUrl + file.hash, filePath); } + + return true; } function launchLauncher() { - console.log("Launching the launcher ! "); + // console.log("Launching the launcher ! "); var launcherPath = path.join(basePath, "bin", "plutonium-launcher-win32.exe"); @@ -201,31 +203,35 @@ function launchLauncher() { var manifestCount = mustSkipCustom ? 1 : manifestURLs.length; for (var m = 0; m < manifestCount; m++) { - console.log("Getting manifest " + (m + 1) + "..."); - try { await readAndMergeManifest(manifestURLs[m]); } catch (error) { console.error("An error has occurred while obtaining manifest " + (m + 1) + " : " + error.message); } - checkFiles().then(function (wrongFiles) { - if (wrongFiles.length > 0) { - console.log("We have " + wrongFiles.length + " files to download. "); - downloadFiles(wrongFiles).then(function () { - launchLauncher().then(function () { - - }).catch(function (error) { - console.error("An error has occurred while opening the launcher. \n" + error.stack); - }); + } + console.log("\x1b[36mChecking the files...\x1b[0m"); + checkFiles().then(function (wrongFiles) { + if (wrongFiles.length > 0) { + console.log("We have " + wrongFiles.length + " files to download. "); + downloadFiles(wrongFiles).then(function () { + launchLauncher().then(function () { }).catch(function (error) { - console.error("An error has occurred while downloading a file. \n" + error.stack); + console.error("An error has occurred while opening the launcher. \n" + error.stack); }); - } else { - console.log("All files seem good ! "); - } - }).catch(function (error) { - console.error("An error has occurred while checking the files. \n" + error.stack); - }); - } + + }).catch(function (error) { + console.error("An error has occurred while downloading a file. \n" + error.stack); + }); + } else { + // console.log("All files seem good ! "); + launchLauncher().then(function () { + + }).catch(function (error) { + console.error("An error has occurred while opening the launcher. \n" + error.stack); + }); + } + }).catch(function (error) { + console.error("An error has occurred while checking the files. \n" + error.stack); + }); })(); diff --git a/package.json b/package.json index d7fac4e..47971c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "open-plutonium-updater", - "version": "0.2.0", + "description": "Updater for Kroniker Project's version of Plutonium Black Ops II", + "version": "0.4.0", "main": "index.js", "author": "X3F200C", "license": "GPL-3.0"