-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
30 lines (22 loc) · 859 Bytes
/
compile.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
/*
***********************************************************************************
TMS.js
compile.js
This file is responsible for compiling TMS.js
IMPORTANT: This file is suposed to run on nodejs - not on nwjs or any
browser.
***********************************************************************************
*/
try {
const fs = require('fs'),
uglifyJs = require('uglify-js'),
originalTs = fs.readFileSync('./src/TMS.ts', 'utf8'),
originalJs = fs.readFileSync('./Compile/TMS.js', 'utf8'),
mFile = uglifyJs.minify(originalJs).code,
final = `${originalTs.slice(0, (originalTs.indexOf('*/') + 2))}\n${mFile}`;
fs.writeFileSync('./Compile/TMS.ts', originalTs, 'utf8');
fs.writeFileSync('./Compile/TMS.js', originalJs, 'utf8');
fs.writeFileSync('./Compile/TMS.min.js', final, 'utf8');
} catch (err) {
throw new Error(err);
}