forked from dreamfliper/subTrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.js
41 lines (34 loc) · 1.06 KB
/
release.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
'use strict'
const exec = require('child_process').exec
const packager = require('electron-packager')
if (process.env.PLATFORM_TARGET === 'clean') {
require('del').sync(['builds/*', '!.gitkeep'])
console.log('\x1b[33m`builds` directory cleaned.\n\x1b[0m')
} else pack()
/**
* Build webpack in production
*/
function pack () {
console.log('\x1b[33mBuilding webpack in production mode...\n\x1b[0m')
let pack = exec('npm run pack')
pack.stdout.on('data', data => console.log(data))
pack.stderr.on('data', data => console.error(data))
pack.on('exit', code => build())
}
/**
* Use electron-packager to build electron app
*/
function build () {
let options = require('../config').building
console.log('\x1b[34mBuilding electron app(s)...\n\x1b[0m')
packager(options, (err, appPaths) => {
if (err) {
console.error('\x1b[31mError from `electron-packager` when building app...\x1b[0m')
console.error(err)
} else {
console.log('Build(s) successful!')
console.log(appPaths)
console.log('\n\x1b[34mDONE\n\x1b[0m')
}
})
}