Skip to content

Commit 9279d27

Browse files
committed
Consistent naming for in LuaLibModulesInfo
1 parent 2d6141f commit 9279d27

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/LuaLib.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,19 @@ export interface LuaLibFeatureInfo {
106106
}
107107
export type LuaLibModulesInfo = Record<LuaLibFeature, LuaLibFeatureInfo>;
108108

109-
let luaLibModuleInfo: LuaLibModulesInfo | undefined;
110-
export function getLuaLibModuleInfo(emitHost: EmitHost): LuaLibModulesInfo {
111-
if (luaLibModuleInfo === undefined) {
112-
const lualibPath = path.resolve(__dirname, "../dist/lualib/lualib_dependencies.json");
109+
export const luaLibModulesInfoFileName = "lualib_module_info.json";
110+
let luaLibModulesInfo: LuaLibModulesInfo | undefined;
111+
export function getLuaLibModulesInfo(emitHost: EmitHost): LuaLibModulesInfo {
112+
if (luaLibModulesInfo === undefined) {
113+
const lualibPath = path.resolve(__dirname, `../dist/lualib/${luaLibModulesInfoFileName}`);
113114
const result = emitHost.readFile(lualibPath);
114115
if (result !== undefined) {
115-
luaLibModuleInfo = JSON.parse(result) as LuaLibModulesInfo;
116+
luaLibModulesInfo = JSON.parse(result) as LuaLibModulesInfo;
116117
} else {
117118
throw new Error(`Could not load lualib dependencies from '${lualibPath}'`);
118119
}
119120
}
120-
return luaLibModuleInfo;
121+
return luaLibModulesInfo;
121122
}
122123

123124
export function readLuaLibFeature(feature: LuaLibFeature, emitHost: EmitHost): string {
@@ -132,7 +133,7 @@ export function readLuaLibFeature(feature: LuaLibFeature, emitHost: EmitHost): s
132133
export function loadInlineLualibFeatures(
133134
features: Iterable<LuaLibFeature>,
134135
emitHost: EmitHost,
135-
luaLibModulesInfo: LuaLibModulesInfo = getLuaLibModuleInfo(emitHost),
136+
luaLibModulesInfo: LuaLibModulesInfo = getLuaLibModulesInfo(emitHost),
136137
readFeature: (feature: LuaLibFeature) => string = feature => readLuaLibFeature(feature, emitHost)
137138
): string {
138139
let result = "";
@@ -163,7 +164,7 @@ export function loadImportedLualibFeatures(
163164
emitHost: EmitHost,
164165
alwaysRequire = false
165166
): lua.Statement[] {
166-
const luaLibModuleInfo = getLuaLibModuleInfo(emitHost);
167+
const luaLibModuleInfo = getLuaLibModulesInfo(emitHost);
167168

168169
const imports = Array.from(features).flatMap(feature => luaLibModuleInfo[feature].exports);
169170

src/transpilation/lualib.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProcessedFile, EmitHost } from "./utils";
2-
import { LuaLibFeature, LuaLibModulesInfo, loadInlineLualibFeatures } from "../LuaLib";
2+
import { LuaLibFeature, LuaLibModulesInfo, loadInlineLualibFeatures, luaLibModulesInfoFileName } from "../LuaLib";
33
import * as path from "path";
44
import { LuaPrinter } from "../LuaPrinter";
55
import * as lua from "../LuaAST";
@@ -72,7 +72,7 @@ export function generateExtraLualibFiles(
7272
},
7373
{
7474
code: JSON.stringify(lualibModulesInfo, null, 2),
75-
fileName: "lualib_dependencies.json",
75+
fileName: luaLibModulesInfoFileName,
7676
isRawFile: true,
7777
},
7878
];

0 commit comments

Comments
 (0)