Implement require option for modules

Implement option allowing files to be required from control.lua be
specified in modules.json.
This commit is contained in:
Hornwitser committed 2020-01-04 17:34:16 +01:00
1 parent e89e54ee27
commit c091dc341e
5 files changed
+45 -13

No files matched your search

+5 -1
View File
@@ -82,10 +82,13 @@ function generateLoader(patchInfo) {
for (let module of patchInfo["modules"]) {
for (let file of module["files"]) {
let requirePath = `modules/${module.name}/${file["path"].slice(0, -4)}`;
if (file["load"]) {
let requirePath = `modules/${module.name}/${file["path"].slice(0, -4)}`;
lines.push('event_handler.add_lib(require("'+requirePath+'"))');
}
if (file["require"]) {
lines.push('require("'+requirePath+'")');
}
}
}
@@ -251,6 +254,7 @@ async function patch(savePath, modules) {
moduleInfo["files"].push({
"path": relativePath,
"load": module.load.includes(relativePath),
"require": module.require.includes(relativePath),
});
} else if (entry.isDirectory()) {