This repository has been archived by the owner on Mar 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildtool.js
67 lines (62 loc) · 2.26 KB
/
buildtool.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
const path = require('path')
const packager = require('electron-packager')
const electronInstaller = require('electron-winstaller')
const createDMG = require('electron-installer-dmg')
const iRegex = /\.git(ignore|modules)|\.npmignore|logs|README\.md|\.vscode|docs|builds|discord_assets|buildtool.js/
const appName = 'LeagueRPC'
const iconPath = path.join(__dirname, 'app', 'assets', 'images', 'league.ico')
const iconPathMac = path.join(__dirname, 'app', 'assets', 'images', 'league.icns')
const buildPath = path.join(__dirname, 'builds')
const p = process.argv[2] != null ? process.argv[2] : process.platform
const a = process.argv[3] != null ? process.argv[3] : process.arch
console.log(`Packaging ${appName} for ${p} ${a}..`)
packager({
dir: '.',
overwrite: true,
out: buildPath,
asar: true,
name: appName,
ignore: iRegex,
icon: iconPath,
prune: true,
platform: p,
arch: a
}).then(appPaths => {
console.log(`Packaged ${p}-${a}`)
if(p === 'win32'){
// TODO Complete options (signature, etc)
console.log(`Building ${p}-${a} installer..`)
electronInstaller.createWindowsInstaller({
appDirectory: appPaths[0],
outputDirectory: path.join(buildPath, `${appName}-${p}-${a}-msi`),
authors: 'Daniel Scalzi',
exe: `${appName}.exe`,
setupIcon: iconPath,
setupExe: `${appName}.exe`,
setupMsi: `${appName}.msi`
}).then(() => {
console.log(`${p}-${a} installer successfully built.`)
}, (e) => {
console.log('Error while building installer:', e.message)
})
} else if(p === 'darwin'){
// TODO Test on macOS
console.log(`Building ${p}-${a} installer..`)
createDMG({
appPath: path.join(appPaths[0], `${appName}.app`),
name: appName,
icon: iconPathMac,
overwrite: true,
debug: true,
out: path.join(buildPath, `${appName}-${p}-${a}-dmg`)
}, (err) => {
if(err){
console.log('Error while building installer:', err.message)
} else {
console.log(`${p}-${a} installer successfully built.`)
}
})
}
}).catch(err => {
console.log(err)
})