Skip to content

Commit 2fc099e

Browse files
committed
Extract luaLibImport to a variable
1 parent 07c23dc commit 2fc099e

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/LuaPrinter.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { TSHelper as tsHelper } from "./TSHelper";
1010
type SourceChunk = string | SourceNode;
1111

1212
export class LuaPrinter {
13-
/* tslint:disable:object-literal-sort-keys */
1413
private static operatorMap: {[key in tstl.Operator]: string} = {
1514
[tstl.SyntaxKind.AdditionOperator]: "+",
1615
[tstl.SyntaxKind.SubractionOperator]: "-",
@@ -38,7 +37,6 @@ export class LuaPrinter {
3837
[tstl.SyntaxKind.BitwiseLeftShiftOperator]: "<<",
3938
[tstl.SyntaxKind.BitwiseNotOperator]: "~",
4039
};
41-
/* tslint:enable:object-literal-sort-keys */
4240

4341
private options: CompilerOptions;
4442
private currentIndent: string;
@@ -122,18 +120,15 @@ export class LuaPrinter {
122120
}
123121

124122
if (luaLibFeatures) {
123+
const luaLibImport = this.options.luaLibImport || LuaLibImportKind.Inline;
125124
// Require lualib bundle
126-
if ((this.options.luaLibImport === LuaLibImportKind.Require && luaLibFeatures.size > 0)
127-
|| this.options.luaLibImport === LuaLibImportKind.Always)
125+
if ((luaLibImport === LuaLibImportKind.Require && luaLibFeatures.size > 0)
126+
|| luaLibImport === LuaLibImportKind.Always)
128127
{
129128
header += `require("lualib_bundle");\n`;
130129
}
131130
// Inline lualib features
132-
else if (
133-
(this.options.luaLibImport === undefined ||
134-
this.options.luaLibImport === LuaLibImportKind.Inline) &&
135-
luaLibFeatures.size > 0
136-
) {
131+
else if (luaLibImport === LuaLibImportKind.Inline && luaLibFeatures.size > 0) {
137132
header += "-- Lua Library inline imports\n";
138133
header += LuaLib.loadFeatures(luaLibFeatures);
139134
}

0 commit comments

Comments
 (0)