UNPKG

electron-builder-util

Version:

Part of [electron-builder](https://github.com/electron-userland/electron-builder).

128 lines (105 loc) 4.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkWineVersion = undefined; var _bluebirdLst; function _load_bluebirdLst() { return _bluebirdLst = require("bluebird-lst"); } /** @private */ let checkWineVersion = exports.checkWineVersion = (() => { var _ref2 = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (checkPromise) { function wineError(prefix) { return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${process.platform === "linux" ? "linux" : "macos"}`; } let wineVersion; try { wineVersion = (yield checkPromise).trim(); } catch (e) { if (e.code === "ENOENT") { throw new Error(wineError("wine is required")); } else { throw new Error(`Cannot check wine version: ${e}`); } } if (wineVersion.startsWith("wine-")) { wineVersion = wineVersion.substring("wine-".length); } const spaceIndex = wineVersion.indexOf(" "); if (spaceIndex > 0) { wineVersion = wineVersion.substring(0, spaceIndex); } const suffixIndex = wineVersion.indexOf("-"); if (suffixIndex > 0) { wineVersion = wineVersion.substring(0, suffixIndex); } if (wineVersion.split(".").length === 2) { wineVersion += ".0"; } if ((0, (_semver || _load_semver()).lt)(wineVersion, "1.8.0")) { throw new Error(wineError(`wine 1.8+ is required, but your version is ${wineVersion}`)); } }); return function checkWineVersion(_x2) { return _ref2.apply(this, arguments); }; })(); //# sourceMappingURL=wine.js.map exports.execWine = execWine; exports.prepareWindowsExecutableArgs = prepareWindowsExecutableArgs; var _lazyVal; function _load_lazyVal() { return _lazyVal = require("lazy-val"); } var _path = _interopRequireWildcard(require("path")); var _semver; function _load_semver() { return _semver = require("semver"); } var _binDownload; function _load_binDownload() { return _binDownload = require("./binDownload"); } var _bundledTool; function _load_bundledTool() { return _bundledTool = require("./bundledTool"); } var _macosVersion; function _load_macosVersion() { return _macosVersion = require("./macosVersion"); } var _util; function _load_util() { return _util = require("./util"); } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } const wineExecutable = new (_lazyVal || _load_lazyVal()).Lazy((0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () { (0, (_util || _load_util()).debug)(`USE_SYSTEM_WINE: ${process.env.USE_SYSTEM_WINE}`); if (!(0, (_util || _load_util()).isEnvTrue)(process.env.USE_SYSTEM_WINE) && (yield (0, (_macosVersion || _load_macosVersion()).isMacOsSierra)())) { // noinspection SpellCheckingInspection const wineDir = yield (0, (_binDownload || _load_binDownload()).getBinFromGithub)("wine", "2.0.1-mac-10.12", "IvKwDml/Ob0vKfYVxcu92wxUzHu8lTQSjjb8OlCTQ6bdNpVkqw17OM14TPpzGMIgSxfVIrQZhZdCwpkxLyG3mg=="); return { path: _path.join(wineDir, "bin/wine"), env: Object.assign({}, process.env, { WINEDEBUG: "-all,err+all", WINEDLLOVERRIDES: "winemenubuilder.exe=d", WINEPREFIX: _path.join(wineDir, "wine-home"), DYLD_FALLBACK_LIBRARY_PATH: (0, (_bundledTool || _load_bundledTool()).computeEnv)(process.env.DYLD_FALLBACK_LIBRARY_PATH, [_path.join(wineDir, "lib")]) }) }; } yield checkWineVersion((0, (_util || _load_util()).exec)("wine", ["--version"])); return { path: "wine" }; })); /** @private */ function execWine(file, args) { let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (_bundledTool || _load_bundledTool()).EXEC_TIMEOUT; if (process.platform === "win32") { return (0, (_util || _load_util()).exec)(file, args, options); } else { return wineExecutable.value.then(wine => (0, (_util || _load_util()).exec)(wine.path, [file].concat(args), wine.env == null ? options : Object.assign({ env: wine.env }, options))); } } /** @private */ function prepareWindowsExecutableArgs(args, exePath) { if (process.platform !== "win32") { args.unshift(exePath); } return args; }