-
Notifications
You must be signed in to change notification settings - Fork 36
/
pack.js
80 lines (70 loc) · 1.75 KB
/
pack.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
/* eslint-disable quote-props */
'use strict'
const pify = require('pify')
const packager = require('electron-packager')
const hardRejection = require('hard-rejection')
const pkg = require('./package.json')
const electronCfg = require('./webpack.config.electron')
hardRejection()
const deps = Object.keys(pkg.dependencies)
const devDeps = Object.keys(pkg.devDependencies)
const ignoredDeps = deps
.filter(name => !electronCfg.externals.includes(name))
.map(name => `/node_modules/${name}($|/)`)
const ignoredDevDeps = devDeps.map(name => `/node_modules/${name}($|/)`)
const ignore = [
'^/test($|/)',
'^/release($|/)',
'^/media($|/)',
'^/static($|/)',
'^/webpack+?',
'^/pack.js$',
'^/interface($|/)',
'^/CSSFlowStub.js.flow',
'^/main.development.js',
...ignoredDevDeps,
...ignoredDeps,
]
function pack(target) {
const buildOpts = {
macos: {
platform: 'darwin',
arch: 'x64',
icon: 'static/Icon.icns',
'app-bundle-id': 'io.github.akameco.pixivdeck',
'osx-sign': true,
},
windows: {
platform: 'win32',
arch: 'ia32',
icon: 'static/Icon.ico',
'app-bundle-id': 'io.github.akameco.pixivdeck',
win32metadata: {
FileDescription: pkg.productName,
},
},
linux: {
platform: 'linux',
arch: 'x64',
icon: 'static/Icon.png',
'version-string.ProductName': pkg.productName,
},
}
const pkgOpt = Object.assign({
dir: './',
name: pkg.productName,
asar: true,
'app-version': pkg.version,
overwrite: true,
prune: true,
out: 'release',
ignore,
}, buildOpts[target])
return pify(packager)(pkgOpt)
}
const input = process.argv.slice(2)[0]
if (!input || !['macos', 'windows', 'linux'].includes(input)) {
console.error('input required')
process.exit(1) // eslint-disable-line xo/no-process-exit
}
pack(input)