66 lines
5.5 KiB
JavaScript
66 lines
5.5 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
require("source-map-support/register");
|
|
|
|
var _installerDarwin = _interopRequireDefault(require("@electron-forge/installer-darwin"));
|
|
|
|
var _crossSpawnPromise = require("@malept/cross-spawn-promise");
|
|
|
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
|
var _path = _interopRequireDefault(require("path"));
|
|
|
|
var _hdiutil = require("./util/hdiutil");
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
class InstallerDMG extends _installerDarwin.default {
|
|
constructor(...args) {
|
|
super(...args);
|
|
|
|
_defineProperty(this, "name", 'dmg');
|
|
}
|
|
|
|
async install({
|
|
filePath,
|
|
installSpinner
|
|
}) {
|
|
const mounts = await (0, _hdiutil.getMountedImages)();
|
|
let targetMount = mounts.find(mount => mount.imagePath === filePath);
|
|
|
|
if (!targetMount) {
|
|
targetMount = await (0, _hdiutil.mountImage)(filePath);
|
|
}
|
|
|
|
try {
|
|
const volumePath = _path.default.resolve('/Volumes', targetMount.mountPath);
|
|
|
|
const appName = (await _fsExtra.default.readdir(volumePath)).find(file => file.endsWith('.app'));
|
|
|
|
if (!appName) {
|
|
throw new Error('Failed to find .app file in DMG');
|
|
}
|
|
|
|
const appPath = _path.default.resolve(volumePath, appName);
|
|
|
|
const targetApplicationPath = `/Applications/${_path.default.basename(appPath)}`;
|
|
await this.moveApp(appPath, targetApplicationPath, installSpinner, true);
|
|
await (0, _crossSpawnPromise.spawn)('open', ['-R', targetApplicationPath], {
|
|
detached: true
|
|
});
|
|
} finally {
|
|
await (0, _hdiutil.unmountImage)(targetMount);
|
|
}
|
|
}
|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