-
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathprinter.ts
More file actions
23 lines (19 loc) · 818 Bytes
/
printer.ts
File metadata and controls
23 lines (19 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { SourceNode } from "source-map";
import * as tstl from "../../../src";
class CustomPrinter extends tstl.LuaPrinter {
/* Override printFile */
protected printFile(file: tstl.File): SourceNode {
const originalResult = super.printFile(file);
// Add header comment at the top of the file
return this.createSourceNode(file, [`-- Custom printer plugin: ${this.luaFile}\n`, originalResult]);
}
/* Override printBoolean */
public printBooleanLiteral(expression: tstl.BooleanLiteral): SourceNode {
// Print any boolean as 'true'
return this.createSourceNode(expression, "true");
}
}
const plugin: tstl.Plugin = {
printer: (program, emitHost, fileName, file) => new CustomPrinter(emitHost, program, fileName).print(file),
};
export default plugin;