forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_lualib.ts
More file actions
19 lines (15 loc) · 731 Bytes
/
build_lualib.ts
File metadata and controls
19 lines (15 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as fs from "fs";
import * as path from "path";
import * as ts from "typescript";
import * as tstl from "./src";
import { loadLuaLibFeatures } from "./src/LuaLib";
const configFileName = path.resolve(__dirname, "src/lualib/tsconfig.json");
const { emitResult, diagnostics } = tstl.transpileProject(configFileName);
emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text));
const reportDiagnostic = tstl.createDiagnosticReporter(true);
diagnostics.forEach(reportDiagnostic);
const bundlePath = path.join(__dirname, "dist/lualib/lualib_bundle.lua");
if (fs.existsSync(bundlePath)) {
fs.unlinkSync(bundlePath);
}
fs.writeFileSync(bundlePath, loadLuaLibFeatures(Object.values(tstl.LuaLibFeature), ts.sys));