/
MakerSnap.ts
38 lines (28 loc) · 920 Bytes
/
MakerSnap.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
import MakerBase, { MakerOptions } from '@electron-forge/maker-base';
import { ForgePlatform } from '@electron-forge/shared-types';
import path from 'path';
import { MakerSnapConfig } from './Config';
export default class MakerSnap extends MakerBase<MakerSnapConfig> {
name = 'snap';
defaultPlatforms: ForgePlatform[] = ['linux'];
isSupportedOnCurrentPlatform() {
return process.platform === 'linux';
}
async make({
dir,
makeDir,
targetArch,
}: MakerOptions) {
// eslint-disable-next-line global-require
const installer = require('electron-installer-snap');
const outPath = path.resolve(makeDir, 'snap', targetArch);
await this.ensureDirectory(outPath);
const snapDefaults = {
arch: targetArch,
dest: outPath,
src: dir,
};
const snapConfig = Object.assign({}, this.config, snapDefaults);
return [await installer(snapConfig)];
}
}