-
-
Notifications
You must be signed in to change notification settings - Fork 490
/
MakerDMG.ts
47 lines (38 loc) · 1.28 KB
/
MakerDMG.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import MakerBase, { MakerOptions } from '@electron-forge/maker-base';
import { ForgePlatform } from '@electron-forge/shared-types';
import fs from 'fs-extra';
import path from 'path';
import { MakerDMGConfig } from './Config';
export default class MakerDMG extends MakerBase<MakerDMGConfig> {
name = 'dmg';
defaultPlatforms: ForgePlatform[] = ['darwin', 'mas'];
isSupportedOnCurrentPlatform() {
return process.platform === 'darwin';
}
async make({
dir,
makeDir,
appName,
packageJSON,
}: MakerOptions) {
// eslint-disable-next-line global-require
const electronDMG = require('electron-installer-dmg');
const outPath = path.resolve(makeDir, `${this.config.name || appName}.dmg`);
const forgeDefaultOutPath = path.resolve(makeDir, `${appName}-${packageJSON.version}.dmg`);
await this.ensureFile(outPath);
const dmgConfig = Object.assign({
overwrite: true,
name: appName,
}, this.config, {
appPath: path.resolve(dir, `${appName}.app`),
out: path.dirname(outPath),
});
const opts = await electronDMG(dmgConfig);
if (!this.config.name) {
await this.ensureFile(forgeDefaultOutPath);
await fs.rename(outPath, forgeDefaultOutPath);
return [forgeDefaultOutPath];
}
return [opts.dmgPath];
}
}