-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.js
58 lines (48 loc) · 1.45 KB
/
package.js
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
48
49
50
51
52
53
54
55
56
57
58
"use strict";
var packager = require('electron-packager');
const pkg = require('./package.json');
const argv = require('minimist')(process.argv.slice(2));
const devDeps = Object.keys(pkg.devDependencies);
const appName = argv.name || pkg.productName;
const shouldUseAsar = argv.asar || false;
const shouldBuildAll = argv.all || false;
const arch = argv.arch || 'all';
const platform = argv.platform || 'darwin';
const DEFAULT_OPTS = {
dir: './src/app',
name: appName,
asar: shouldUseAsar,
ignore: [
].concat(devDeps.map(name => `/node_modules/${name}($|/)`))
};
const icon = './src/app/dist/assets/app-icon';
if (icon) {
DEFAULT_OPTS.icon = icon;
}
pack(platform, arch, function done(err, appPath) {
console.log(err);
});
function pack(plat, arch, cb) {
// there is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return;
const iconObj = {
icon: DEFAULT_OPTS.icon + (() => {
let extension = '.png';
if (plat === 'darwin') {
extension = '.icns';
} else if (plat === 'win32') {
extension = '.ico';
}
return extension;
})()
};
const opts = Object.assign({}, DEFAULT_OPTS, iconObj, {
platform: plat,
arch,
prune: true,
all: shouldBuildAll,
'app-version': pkg.version || DEFAULT_OPTS.version,
out: `release/${plat}-${arch}`
});
packager(opts, cb);
}