UNPKG

@overwolf/ow-app-builder-lib

Version:
64 lines 2.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OWUtilityHelper = void 0; const builder_util_1 = require("builder-util"); const binDownload_1 = require("../../binDownload"); const electronVersion_1 = require("../../electron/electronVersion"); //------------------------------------------------------------------------------ class OWUtilityHelper { //---------------------------------------------------------------------------- constructor(appOutDir, config) { this.libName = 'owutility.dll'; this.remoteLibPath = 'https://content.overwolf.com/ow-electron/releases/download/owutility'; this.appOutDir = appOutDir; this.configuration = config; } //---------------------------------------------------------------------------- async ensureLatest() { var _a; if ((_a = this.configuration.overwolf) === null || _a === void 0 ? void 0 : _a.disableAdOptimization) { builder_util_1.log.info('skipping owutility - disableAdOptimization enabled'); return true; } builder_util_1.log.info('downloading and packing owutility.dll'); const electronVersion = await (0, electronVersion_1.getElectronVersion)(process.cwd()); var exists = await this.getSpecificLibVersion(electronVersion); if (exists) { return true; } // get general lib version return await this.getGeneralLibVersion(); } //---------------------------------------------------------------------------- /** * Get owutility lib for the specific electron version * @returns true if a specific version was successfully found, false if tried * to update and failed. Throws an exception if not found. */ async getSpecificLibVersion(electronVer) { const specificVersionUrl = `${this.remoteLibPath}/${electronVer}/${this.libName}`; return this.download(specificVersionUrl); } //---------------------------------------------------------------------------- /** * Get owutility lib that doesn't target a specific version * @returns true if a specific version was successfully updated, otherwise * false */ async getGeneralLibVersion() { const generalVersionUrl = `${this.remoteLibPath}/${this.libName}`; return this.download(generalVersionUrl); } //---------------------------------------------------------------------------- async download(url) { try { await (0, binDownload_1.download)(url, `${this.appOutDir}/${this.libName}`, null, true); return true; } catch (e) { return false; } } } exports.OWUtilityHelper = OWUtilityHelper; //# sourceMappingURL=OWUtilityHelper.js.map