Skip to content

Commit

Permalink
feat(installer): add DMG support for macOS installer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Dec 31, 2016
1 parent 5cbf8cb commit 3465d26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/electron-forge-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import semver from 'semver';

import './util/terminate';

import darwinDMGInstaller from './installers/darwin/dmg';
import darwinZipInstaller from './installers/darwin/zip';

const d = debug('electron-forge:lint');
Expand Down Expand Up @@ -72,7 +73,7 @@ const main = async () => {

const installTargets = {
win32: ['.exe'],
darwin: ['OSX.zip', 'darwin.zip', 'macOS.zip', 'mac.zip'],
darwin: ['OSX.zip', 'darwin.zip', 'macOS.zip', 'mac.zip', '.dmg'],
linux: ['.rpm', '.deb', '.flatpak'],
};

Expand Down Expand Up @@ -130,6 +131,7 @@ const main = async () => {
},
darwin: {
'.zip': darwinZipInstaller,
'.dmg': darwinDMGInstaller,
},
linux: {
'.deb': async () => {},
Expand Down
14 changes: 14 additions & 0 deletions src/installers/darwin/dmg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fs from 'fs-promise';
import opn from 'opn';
import path from 'path';
import pify from 'pify';
import { exec } from 'child_process';

export default async (filePath) => {
const DMGPath = path.join(path.dirname(filePath), path.parse(filePath).name);
if (await fs.exists(DMGPath)) {
await fs.remove(DMGPath);
}
await pify(exec)(`cp "${filePath}" "${DMGPath}"`);
await opn(DMGPath, { wait: false });
};

0 comments on commit 3465d26

Please sign in to comment.