Skip to content

Commit ef6ad0e

Browse files
committed
Adde missing .lua extension
1 parent 586381c commit ef6ad0e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/Transpiler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,13 @@ export abstract class LuaTranspiler {
320320

321321
const imports = node.importClause.namedBindings;
322322

323+
const reqKeyword = this.getRequireKeyword();
324+
323325
if (ts.isNamedImports(imports)) {
324326
const fileImportTable = path.basename(importPathWithoutQuotes) + this.importCount;
325327
const resolvedImportPath = this.getImportPath(importPathWithoutQuotes);
326328

327-
let result = `local ${fileImportTable} = ${this.getRequireKeyword()}(${resolvedImportPath})\n`;
329+
let result = `local ${fileImportTable} = ${reqKeyword}(${resolvedImportPath})\n`;
328330
this.importCount++;
329331

330332
imports.elements.forEach(element => {
@@ -340,7 +342,7 @@ export abstract class LuaTranspiler {
340342
return result;
341343
} else if (ts.isNamespaceImport(imports)) {
342344
const resolvedImportPath = this.getImportPath(importPathWithoutQuotes);
343-
return `local ${this.transpileIdentifier(imports.name)} = require(${resolvedImportPath})\n`;
345+
return `local ${this.transpileIdentifier(imports.name)} = ${reqKeyword}(${resolvedImportPath})\n`;
344346
} else {
345347
throw TSTLErrors.UnsupportedImportType(imports);
346348
}

src/targets/Transpiler.GLua.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export class LuaTranspilerGLua extends LuaTranspiler {
77
public getImportPath(relativePath: string): string {
88
if (path.isAbsolute(relativePath)) {
99
// Get Path relative to baseDir (baseDir should be set to /lua/)
10-
return `"${this.getAbsoluteImportPath(relativePath)}"`;
10+
return `"${this.getAbsoluteImportPath(relativePath)}.lua"`;
1111
} else {
1212
// We can use realtive paths in gmod
13-
return `"${this.pathToLuaRequirePath(relativePath)}"`;
13+
return `"${relativePath}.lua"`;
1414
}
1515
}
1616

0 commit comments

Comments
 (0)