-
Notifications
You must be signed in to change notification settings - Fork 0
/
compileTs.js
50 lines (26 loc) · 812 Bytes
/
compileTs.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
const { exec } = require("child_process");
const fs = require("fs");
const nodePath = require("path");
const parse = (objects, path, finalCallback) => {
for(let i = 0; i < objects.length; ++i) {
const object = nodePath.join( path, objects[i] );
if(fs.lstatSync(object).isDirectory()) {
parse( fs.readdirSync( object ), object );
} else {
const content = fs.readFileSync(object).toString();
fs.writeFileSync(object, content.replace(/\.default/g, ""));
}
}
if(typeof finalCallback == "function") finalCallback();
};
exec("tsc", (error, stderr) => {
if(stderr) {
console.log(stderr);
return;
}
console.log("TSC: Done!")
const path = nodePath.join( __dirname, "./dist" );
parse( fs.readdirSync( path ) , path, () => {
console.log("PostCompile: Done!");
});
});