mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Rework module loading
Change module loading to use a module.json file describing the module and patch in all files in a directory path passed to the patcher instead of having to pass the files names and their content. This allows the specification of which files should be passed to the event_handler lib and an easy implementation of loading stand alone modules.
This commit is contained in:
1 parent
11992d1839
commit
80bd75ba16
11 files changed
+120
-47
No files matched your search
@@ -23,18 +23,23 @@ describe("Integration of lib/factorio/patch", function() {
|
||||
slowTest(this);
|
||||
await factorio.patch(savePath, [{
|
||||
name: "test",
|
||||
files: [{ path: "test.lua", content: "-- test" }]
|
||||
path: "test/file/modules/test",
|
||||
load: [],
|
||||
}, {
|
||||
name: "subdir",
|
||||
path: "test/file/modules/subdir",
|
||||
load: [],
|
||||
}]);
|
||||
|
||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
||||
let content = await zip.file("test/modules/test.lua").async("string");
|
||||
assert.equal(content, "-- test");
|
||||
assert.equal(await zip.file("test/modules/test/test.lua").async("string"), "-- test\n");
|
||||
assert.equal(await zip.file("test/modules/subdir/dir/test.lua").async("string"), "-- test\n");
|
||||
});
|
||||
it("should remove old modules in a save", async function() {
|
||||
slowTest(this);
|
||||
await factorio.patch(savePath, [{ name: "test", files: [] }]);
|
||||
await factorio.patch(savePath, []);
|
||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
||||
assert.equal(zip.file("test/modules/test.lua"), null);
|
||||
assert.equal(zip.file("test/modules/test/test.lua"), null);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user