Fix launcher not opening if no files have to be downloaded and add more info to package.json
This commit is contained in:
parent
01915233c0
commit
3e5e0c56cf
54
index.js
54
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);
|
||||
});
|
||||
})();
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user