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:
Cooldude2606 authored and GitHub committed 2023-08-27 17:47:37 +02:00
1 parent ee105e0e28
commit a4893751e9
3 files changed
+31

No files matched your search

+6
View File
@@ -47,6 +47,12 @@ export class SaveModule {
if (entry.isFile()) {
let savePath = SaveModule.moduleFilePath(relativePath, this.info.name);
this.files.set(savePath, await fs.readFile(fsPath));
if (relativePath == "module_exports.lua") {
this.files.set(
`modules/${this.info.name}.lua`,
Buffer.from(`return require("modules/${this.info.name}/module_exports")`, "utf-8")
);
}
} else if (entry.isDirectory()) {
dirs.push([fsPath, relativePath]);