8000 Dynamically require a file where the path is given on the command line · Issue #321 · luau-lang/lute · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Dynamically require a file where the path is given on the command line #321
@JohnnyMorganz

Description

@JohnnyMorganz

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestruntimeWork in the C++ runtime portion of the code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0