Open
Description
More of a question about what's the best way to do this. Or if it's not possible, how to make it possible.
I have a tool that needs to dynamically require Luau code that is provided on the command line:
lute tool.luau <path/to/loaded/file.luau>
In tool.luau, it works like:
local arguments = { ... }
local path = arguments[1]
local func = require(path)
func() -- `path` returns a function that can get called
Right now, this doesn't work as expected when a file path is given. Due to the way require
works, the path given needs to be relative to the tool.luau
file, rather than the current working directory where lute
was executed. Also, absolute paths are not supported, so I cannot do process.cwd() .. "/" .. path
i.e., in the following situation:
- project
tool.luau
- current
apply.luau
Where my cwd is current
: lute ../project/tool.luau ./apply.luau
fails, but lute ../project/tool.luau ../current/apply
works