Fix launcher not opening if no files have to be downloaded and add more info to package.json

This commit is contained in:
X3F200C 2023-08-07 20:21:46 -04:00
parent 01915233c0
commit 3e5e0c56cf
2 changed files with 32 additions and 25 deletions

View File

@ -153,7 +153,7 @@ async function checkFiles() {
var filePath = path.join(basePath, ...(file.name.split("/"))); var filePath = path.join(basePath, ...(file.name.split("/")));
if (!fs.existsSync(filePath)) { 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); filesToDownload.push(file);
continue; continue;
} }
@ -161,10 +161,10 @@ async function checkFiles() {
var sum = await getFileSHA1(filePath); var sum = await getFileSHA1(filePath);
if (sum !== file.hash) { 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); filesToDownload.push(file);
} else { } 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 file = files[f];
var filePath = path.join(basePath, ...(file.name.split("/"))); 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); await httpsDownload(file.baseUrl + file.hash, filePath);
} }
return true;
} }
function launchLauncher() { function launchLauncher() {
console.log("Launching the launcher ! "); // console.log("Launching the launcher ! ");
var launcherPath = path.join(basePath, "bin", "plutonium-launcher-win32.exe"); var launcherPath = path.join(basePath, "bin", "plutonium-launcher-win32.exe");
@ -201,13 +203,13 @@ function launchLauncher() {
var manifestCount = mustSkipCustom ? 1 : manifestURLs.length; var manifestCount = mustSkipCustom ? 1 : manifestURLs.length;
for (var m = 0; m < manifestCount; m++) { for (var m = 0; m < manifestCount; m++) {
console.log("Getting manifest " + (m + 1) + "...");
try { try {
await readAndMergeManifest(manifestURLs[m]); await readAndMergeManifest(manifestURLs[m]);
} catch (error) { } catch (error) {
console.error("An error has occurred while obtaining manifest " + (m + 1) + " : " + error.message); console.error("An error has occurred while obtaining manifest " + (m + 1) + " : " + error.message);
} }
}
console.log("\x1b[36mChecking the files...\x1b[0m");
checkFiles().then(function (wrongFiles) { checkFiles().then(function (wrongFiles) {
if (wrongFiles.length > 0) { if (wrongFiles.length > 0) {
console.log("We have " + wrongFiles.length + " files to download. "); console.log("We have " + wrongFiles.length + " files to download. ");
@ -222,10 +224,14 @@ function launchLauncher() {
console.error("An error has occurred while downloading a file. \n" + error.stack); console.error("An error has occurred while downloading a file. \n" + error.stack);
}); });
} else { } else {
console.log("All files seem good ! "); // 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) { }).catch(function (error) {
console.error("An error has occurred while checking the files. \n" + error.stack); console.error("An error has occurred while checking the files. \n" + error.stack);
}); });
}
})(); })();

View File

@ -1,6 +1,7 @@
{ {
"name": "open-plutonium-updater", "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", "main": "index.js",
"author": "X3F200C", "author": "X3F200C",
"license": "GPL-3.0" "license": "GPL-3.0"