forked from tswow/tswow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
56 lines (48 loc) · 1.96 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
49
50
51
52
53
54
55
56
/**
* This file is used to bootstrap the other compiler scripts.
*/
const child_process = require('child_process');
const path = require('path');
const fs = require('fs')
if(!fs.existsSync('./build.conf')) {
fs.copyFileSync('./build.default.conf','./build.conf');
}
const buildConf = fs.readFileSync('./build.conf','utf-8')
const buildDir = buildConf.match(/^BuildDirectory *= *"(.+?)"/m)[1]
const installDir = buildConf.match(/^InstallDirectory *= *"(.+?)"/m)[1]
const displayNames = (buildConf.match(/^Terminal\.DisplayNames *= *(.+)/m)||['','true'])[1]
const displayTimestamps = (buildConf.match(/^Terminal\.DisplayTimestamps *= *(.+)/m)||['','true'])[1]
const shouldDisplayNames = displayNames === 'true'
|| displayNames === '1'
const shouldDisplayTimestamps = displayTimestamps === 'true'
|| displayTimestamps === '1'
const bootstrapDir = path.join(buildDir,'bootstrap')
const buildScripts = () =>
child_process.execSync(
`npx swc tswow-scripts -d ${bootstrapDir}`
, {stdio:'inherit'}
)
try { buildScripts() }
catch(error) {
child_process.execSync('npm i')
try { buildScripts() }
catch(error) {
console.log(`Failed to bootstrap tswow: ${error}`);
process.exit(0)
}
}
child_process.execSync('npx swc --version', {stdio:'inherit'})
fs.copyFileSync('package-lock.json', path.join(buildDir, 'package-lock.json'))
fs.copyFileSync('package.json',path.join(buildDir,'package.json'))
child_process.execSync('npm i', {cwd:buildDir,stdio:'inherit'});
child_process.execSync('npm i source-map-support --no-save',{stdio:'inherit'})
child_process.execSync(
`node -r source-map-support/register`
+ ` ${path.join(bootstrapDir,'compile','CompileTsWow.js')}`
+ ` ${process.argv.slice(2).join(' ')}`
+ ` --ignore **/wotlkdata/**`
+ ` --ipaths=${installDir}`
+ ` --bpaths=${buildDir}`
+ ` ${shouldDisplayNames?'--displayNames':''}`
+ ` ${shouldDisplayTimestamps?'--displayTimestamps':''}`
,{stdio:'inherit'});