mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Add module export detection (#505)
Allow modules to include a module_exports.lua file in their root which will cause the file save/modules/module_name.lua to be generated pointing to the exports file.
This commit is contained in:
1 parent
ee105e0e28
commit
a4893751e9
3 files changed
+31
No files matched your search
@@ -28,6 +28,30 @@ describe("host/patch", function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadFiles()", function() {
|
||||
const testModule = new patch.SaveModule(new lib.ModuleInfo("test", "1.0.0"));
|
||||
const referenceFiles = new Map([
|
||||
["modules/test/test.lua", "-- test\n"],
|
||||
["modules/test/module_exports.lua", "-- module_exports\n"],
|
||||
["locale/en/test.cfg", "module-test=A Test\n"],
|
||||
["locale/en/test-locale.cfg", "module-test-locale=Test Locale\n"],
|
||||
["modules/test.lua", "return require(\"modules/test/module_exports\")"],
|
||||
]);
|
||||
before(async function() {
|
||||
await testModule.loadFiles("test/file/modules/test");
|
||||
});
|
||||
it("Should read the contents of all files in a module", function() {
|
||||
assert.equal(testModule.files.size, referenceFiles.size);
|
||||
for (let [relativePath, contents] of referenceFiles) {
|
||||
if (!testModule.files.has(relativePath)) {
|
||||
assert.fail(`Module is missing file: ${relativePath}`);
|
||||
} else {
|
||||
assert.equal(testModule.files.get(relativePath).toString("utf-8"), contents);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("generateLoader()", function() {
|
||||
|
||||
Reference in new issue
Block a user