Closed timstableford closed 1 year ago
There currently seems to be two approaches to this:
I'm currently most leaning towards the latter because it's more flexible. Along with this it would be nice to provide some utility functions in thread such as createTable and getTable which would both accept a callback where you do actions on the table and then throw an error if the stack wasn't properly balanced. Maybe an upsertTable too to allow overriding pre-loaded tables.
I added a way to set in the module, shared by the factory in https://github.com/ceifa/wasmoon/commit/675216a2c61b228e2e31b18e54cf8266a29063f2
Maybe it's not the best solution, but now you can share the node process environment variables with the module easily:
const factory = new LuaFactory(undefined, process.env)
NOTE: It will not share a reference to process.env
, the entire object will be copied and will not watch for modifications.
Lua can access the env through os.getenv(name). Expose a way of setting that environment variable map.