-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate exceptions from parallel where possible
- Loading branch information
Showing
7 changed files
with
201 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...e/src/main/resources/data/computercraft/lua/rom/modules/main/cc/internal/tiny_require.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- SPDX-FileCopyrightText: 2025 The CC: Tweaked Developers | ||
-- | ||
-- SPDX-License-Identifier: MPL-2.0 | ||
|
||
--[[- A minimal implementation of require. | ||
This is intended for use with APIs, and other internal code which is not run in | ||
the [`shell`] environment. This allows us to avoid some of the overhead of | ||
loading the full [`cc.require`] module. | ||
> [!DANGER] | ||
> This is an internal module and SHOULD NOT be used in your own code. It may | ||
> be removed or changed at any time. | ||
@local | ||
@tparam string name The module to require. | ||
@return The required module. | ||
]] | ||
|
||
local loaded = {} | ||
local env = setmetatable({}, { __index = _G }) | ||
local function require(name) | ||
local result = loaded[name] | ||
if result then return result end | ||
|
||
local path = "rom/modules/main/" .. name:gsub("%.", "/") | ||
if fs.exists(path .. ".lua") then | ||
result = assert(loadfile(path .. ".lua", nil, env))() | ||
else | ||
result = assert(loadfile(path .. "/init.lua", nil, env))() | ||
end | ||
loaded[name] = result | ||
return result | ||
end | ||
env.require = require | ||
return require |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters