|
1 | 1 | import * as fs from "fs"; |
2 | | -import * as glob from "glob"; |
3 | 2 | import * as path from "path"; |
4 | 3 | import * as ts from "typescript"; |
5 | 4 | import * as tstl from "./src"; |
6 | 5 | import { LuaLib } from "./src/LuaLib"; |
7 | 6 |
|
8 | | -const options: tstl.CompilerOptions = { |
9 | | - skipLibCheck: true, |
10 | | - types: [], |
11 | | - target: ts.ScriptTarget.ESNext, |
12 | | - lib: ["lib.esnext.d.ts"], |
13 | | - |
14 | | - outDir: path.join(__dirname, "./dist/lualib"), |
15 | | - rootDir: path.join(__dirname, "./src/lualib"), |
16 | | - |
17 | | - luaLibImport: tstl.LuaLibImportKind.None, |
18 | | - luaTarget: tstl.LuaTarget.Lua51, |
19 | | - noHeader: true, |
20 | | -}; |
21 | | - |
22 | | -// TODO: Check diagnostics |
23 | | -const { emitResult } = tstl.transpileFiles(glob.sync("./src/lualib/**/*.ts"), options); |
| 7 | +const configFileName = path.resolve(__dirname, "src/lualib/tsconfig.json"); |
| 8 | +const { emitResult, diagnostics } = tstl.transpileProject(configFileName); |
24 | 9 | emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text)); |
25 | 10 |
|
26 | | -const bundlePath = path.join(__dirname, "./dist/lualib/lualib_bundle.lua"); |
| 11 | +const reportDiagnostic = tstl.createDiagnosticReporter(true); |
| 12 | +diagnostics.forEach(reportDiagnostic); |
| 13 | + |
| 14 | +const bundlePath = path.join(__dirname, "dist/lualib/lualib_bundle.lua"); |
27 | 15 | if (fs.existsSync(bundlePath)) { |
28 | 16 | fs.unlinkSync(bundlePath); |
29 | 17 | } |
|
0 commit comments