summaryrefslogtreecommitdiff
path: root/src/main/manaplus/manaApp/windows.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/manaplus/manaApp/windows.ts')
-rw-r--r--src/main/manaplus/manaApp/windows.ts45
1 files changed, 8 insertions, 37 deletions
diff --git a/src/main/manaplus/manaApp/windows.ts b/src/main/manaplus/manaApp/windows.ts
index ed9e70c..7bf5adb 100644
--- a/src/main/manaplus/manaApp/windows.ts
+++ b/src/main/manaplus/manaApp/windows.ts
@@ -4,7 +4,11 @@ import * as fs from "fs-extra";
import { Status } from "../../status";
import { download, Progress as ProgressType } from "../../util/downloader";
import * as extract from "extract-zip";
-import { getRequest } from "../../util/webrequest";
+import {
+ getInstalledManaplusVersion,
+ getVersionInfoForPlatform,
+ updateAvailable,
+} from "./shared";
export class ManaPlusAppWindows implements ManaPlusApp {
private path: string;
@@ -23,23 +27,7 @@ export class ManaPlusAppWindows implements ManaPlusApp {
return this.path + "\\Mana\\";
}
getVersion(): Promise<string> {
- return new Promise((res, rej) => {
- let output: string;
- const child = require("child_process").execFile(
- this.startCommand,
- ["-v"],
- function (err: Error, data: any) {
- output = data.toString();
- }
- );
- child.on("close", () => {
- output = output.replace(this.versionRegEx, "$1");
- res(output);
- });
- child.on("error", () => {
- rej(new Error("Version check failed"));
- });
- });
+ return getInstalledManaplusVersion(this.startCommand, this.versionRegEx);
}
isInstalled(): boolean {
return fs.existsSync(this.path + "\\Mana\\manaplus.exe");
@@ -53,10 +41,7 @@ export class ManaPlusAppWindows implements ManaPlusApp {
Status.setActivity("Fetching Download URL");
let downloadURL;
try {
- let versions = await getRequest(
- "https://tmw2.org/manalauncher/versions.json?" + Date.now()
- );
- downloadURL = versions.windows64.file;
+ downloadURL = (await getVersionInfoForPlatform("windows64")).file;
} catch (e) {
console.log(e);
throw new Error("Download Url fetching error");
@@ -147,20 +132,6 @@ export class ManaPlusAppWindows implements ManaPlusApp {
isNewVersion: boolean;
newestVersion: string;
}> {
- try {
- let versions = await getRequest(
- "https://tmw2.org/manalauncher/versions.json?" + Date.now()
- );
- let currect_version = (await this.isInstalled)
- ? await this.getVersion()
- : "-";
- return {
- isNewVersion:
- currect_version.indexOf(versions.windows64.version) === -1,
- newestVersion: versions.windows64.version,
- };
- } catch (e) {
- throw e;
- }
+ return updateAvailable("windows64", this);
}
}