Skip to content

Commit 837deef

Browse files
committed
Fixed inlining happening after return & changed addheader optio flag to => noHeader
1 parent 8a63a99 commit 837deef

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

build_lualib.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ compile([
77
"none",
88
"--luaTarget",
99
"5.1",
10+
"--noHeader",
1011
"--outDir",
1112
"./dist/lualib",
1213
"--rootDir",

src/CommandLineParser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ export class CLIError extends Error {
1818
}
1919

2020
const optionDeclarations: { [key: string]: yargs.Options } = {
21-
addHeader: {
22-
alias: ["ah", "header"],
23-
default: true,
21+
noHeader: {
22+
default: false,
2423
describe: "Specify if a header will be added to compiled files.",
2524
type: "boolean",
2625
},

src/Transpiler.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ export abstract class LuaTranspiler {
187187
result += "local exports = exports or {}\n";
188188
}
189189

190+
// Inline lualib features
191+
if (this.options.luaLibImport === LuaLibImportKind.Inline) {
192+
for (const feature of this.luaLibFeatureSet) {
193+
const featureFile = path.resolve(__dirname, `../dist/lualib/${feature}.lua`);
194+
result += fs.readFileSync(featureFile) + "\n";
195+
}
196+
}
197+
190198
// Transpile content statements
191199
this.exportStack.push([]);
192200
this.sourceFile.statements.forEach(s => result += this.transpileNode(s));
@@ -195,13 +203,6 @@ export abstract class LuaTranspiler {
195203
if (this.isModule) {
196204
result += "return exports\n";
197205
}
198-
199-
if (this.options.luaLibImport === LuaLibImportKind.Inline) {
200-
for (const feature of this.luaLibFeatureSet) {
201-
const featureFile = path.resolve(__dirname, `../dist/lualib/${feature}.lua`);
202-
result += fs.readFileSync(featureFile) + "\n";
203-
}
204-
}
205206
return result;
206207
}
207208

0 commit comments

Comments
 (0)