-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.js
88 lines (71 loc) · 1.75 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var packager = require('electron-packager')
var assign = require('object-assign')
var del = require('del')
var latest = require('github-latest-release')
var argv = require('minimist')(process.argv.slice(2))
var devDeps = Object.keys(require('./package.json').devDependencies)
var appName = argv.name || argv.n || 'ElectronReact'
var shouldUseAsar = argv.asar || argv.a || false
var DEFAULT_OPTS = {
dir: './',
name: appName,
asar: shouldUseAsar,
ignore: [
'/test($|/)',
'/tools($|/)',
'/release($|/)'
].concat(devDeps.map(function(name) { return '/node_modules/' + name + '($|/)' }))
}
var icon = argv.icon || argv.i
if (icon) {
DEFAULT_OPTS.icon = icon
}
var version = argv.version || argv.v
if (version) {
DEFAULT_OPTS.version = version
packForPlatforms()
} else {
latest('atom', 'electron', function(err, res) {
if (err) {
DEFAULT_OPTS.version = '0.27.1'
} else {
DEFAULT_OPTS.version = res.name.split('v')[1]
}
packForPlatforms()
})
}
var MacOS_OPTS, Linux_OPTS, Windows_OPTS
function assignOpts() {
MacOS_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'darwin',
arch: 'x64',
out: 'release/darwin',
})
Linux_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'linux',
arch: 'x64',
out: 'release/linux',
})
Windows_OPTS = assign({}, DEFAULT_OPTS, {
platform: 'win32',
arch: 'x64',
out: 'release/win32',
})
}
function packForPlatforms() {
assignOpts()
del.sync('release')
pack(MacOS_OPTS, thenPack(Linux_OPTS, thenPack(Windows_OPTS, log)))
}
function pack(opts, cb) {
packager(opts, cb)
}
function thenPack(opts, cb) {
return function() {
packager(opts, cb)
}
}
function log(err, filepath) {
if (err) return console.error(err)
console.log('finished!')
}