-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
87 lines (79 loc) · 2.92 KB
/
build.ps1
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
81
82
83
84
85
86
87
param(
[switch]$help,
[switch]$debug,
[switch]$release,
[switch]$generate,
[switch]$clean
)
function Display_Help {
Write-Host
Write-Host " Compiles and generates the Scriptures."
Write-Host
Write-Host "Parameters:"
Write-Host " -help: Brings up this help message."
Write-Host " -debug: Compiles JavaScript files in debug mode. Optionally cleans old files."
Write-Host " -release: Compiles JavaScript files in release mode. Always cleans old files."
Write-Host " -generate: Compiles Data files. Optionally cleans old files."
Write-Host " -clean: Removes all compiled JavaScript files with debug and release,"
Write-Host " and all data files with generate before recompiling them."
Write-Host
}
if ($help.IsPresent) {
Display_Help
}
else {
if ((Get-Command "node" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host
Write-Host "This program requires Node.js to be installed and available in the PATH."
Write-Host
}
elseif ((Get-Command "tsc" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host
Write-Host "This program requires tsc, the TypeScript compiler, to be installed and available in the PATH."
Write-Host
}
elseif ((Get-Command "terser" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host
Write-Host "This program requires terser to be installed and available in the PATH."
Write-Host
}
elseif ($debug.IsPresent -and $release.IsPresent) {
Write-Host
Write-Host "This program requires either the debug flag or the release flag, but cannot proceed with both."
Write-Host
}
elseif ($debug.IsPresent -or $release.IsPresent -or $generate.IsPresent) {
if ($debug.IsPresent -or $release.IsPresent) {
if ($clean.IsPresent -or $release.IsPresent) {
Write-Host " Removing old JavaScript..."
if (Test-Path ./js -PathType Container) {
Remove-Item -Recurse -Force ./js
}
}
Write-Host " Compiling TypeScript into JavaScript..."
tsc --build
if ($release.IsPresent) {
Write-Host " Minifying all JavaScript files..."
node ./js/tool/minify.js
Write-Host " Removing Asserts from JavaScript files..."
node ./js/tool/remove_asserts.js
}
}
if ($generate.IsPresent) {
if ($clean.IsPresent) {
node ./js/tool/generate.js --force
}
else {
node ./js/tool/generate.js
}
}
if ($debug.IsPresent -or $release.IsPresent) {
Write-Host " Updating Data Consts..."
node ./js/tool/update_data_consts.js
}
Write-Host " Done building."
}
else {
Display_Help
}
}