-
Notifications
You must be signed in to change notification settings - Fork 50
/
build.js
48 lines (36 loc) · 1.33 KB
/
build.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
const { exec } = require('child_process')
const { join } = require('path')
const { cwd } = require('process')
process.env['PKG_CACHE_PATH'] = join(cwd(), 'cache')
process.env['MAKE_JOB_COUNT'] = 8
/**
* Execute command
* @param {string} cmd
* @param {boolean} slient
* @returns {Promise<string>}
*/
function execCommand(cmd, slient = false) {
return new Promise((res, rej) => {
const cp = exec(cmd, { env: process.env, cwd: cwd() })
if (!slient) cp.stdout.pipe(process.stdout)
cp.on('exit', () => res())
cp.on('error', (err) => rej(err))
})
}
(async () => {
const mode = process.argv.find(arg => arg.indexOf('-mode:') === 0)?.split(':')?.[1]?.toLowerCase() || null
console.log('Welcome to Wangsheng Funeral Parlor~')
console.log('Building development...')
await execCommand('tsc --incremental')
console.log('Resolving alias...')
await execCommand('tsc-alias')
if (mode === 'dev') return console.log('Build complete.')
console.log('Building release...')
await execCommand('webpack --config webpack.config.js')
if (mode === 'rel') return console.log('Build complete.')
console.log('Preparing node binary...')
await require('./prepNodeBin')()
console.log('Packing executable...')
await execCommand('pkg . --compress Brotli -o "dist/HuTao-GS.exe" --build', true)
console.log('Build complete.')
})()