mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-21 10:56:58 +00:00
Move our internal module into the main package path
I originally put cc.import in a separate directory from the main modules. This means that programs must extend the package path in order to import these modules. However, this ends up being a mixed blessing: while it makes it much harder for users to accidentally require user code, it also means we can't expose a public interface which wraps a private module. Instead, cc.import now lives on the main package path, but lives under the cc.internal namespace and is not documented anywhere. Hopefully this should be enough of a clue that one shouldn't use it :p.
This commit is contained in:
parent
bdecb88cca
commit
34a31abd9c
@ -51,7 +51,7 @@ fabric-loom = "1.0-SNAPSHOT"
|
|||||||
forgeGradle = "5.1.+"
|
forgeGradle = "5.1.+"
|
||||||
githubRelease = "2.2.12"
|
githubRelease = "2.2.12"
|
||||||
ideaExt = "1.1.6"
|
ideaExt = "1.1.6"
|
||||||
illuaminate = "0.1.0-7-g2a5a89c"
|
illuaminate = "0.1.0-12-ga03e9cd"
|
||||||
librarian = "1.+"
|
librarian = "1.+"
|
||||||
minotaur = "2.+"
|
minotaur = "2.+"
|
||||||
mixinGradle = "0.7.+"
|
mixinGradle = "0.7.+"
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
-- Internal module for handling file uploads. This has NO stability guarantees,
|
--[[- Upload a list of files, as received by the @{event!file_transfer} event.
|
||||||
-- and so SHOULD NOT be relyed on in user code.
|
|
||||||
|
:::warning
|
||||||
|
This is an internal module and SHOULD NOT be used in your own code. It may
|
||||||
|
be removed or changed at any time.
|
||||||
|
:::
|
||||||
|
|
||||||
|
@local
|
||||||
|
]]
|
||||||
|
|
||||||
local completion = require "cc.completion"
|
local completion = require "cc.completion"
|
||||||
|
|
||||||
|
--- @tparam { file_transfer.TransferredFile ...} files The files to upload.
|
||||||
return function(files)
|
return function(files)
|
||||||
local overwrite = {}
|
local overwrite = {}
|
||||||
for _, file in pairs(files) do
|
for _, file in pairs(files) do
|
@ -18,7 +18,5 @@ if #files == 0 then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
package.path = package.path .. ";/rom/modules/internal/?.lua"
|
local ok, err = require("cc.internal.import")(files)
|
||||||
|
|
||||||
local ok, err = require("cc.import")(files)
|
|
||||||
if not ok and err then printError(err) end
|
if not ok and err then printError(err) end
|
||||||
|
@ -37,7 +37,7 @@ end
|
|||||||
-- Set up a dummy require based on the current shell, for loading some of our internal dependencies.
|
-- Set up a dummy require based on the current shell, for loading some of our internal dependencies.
|
||||||
local require
|
local require
|
||||||
do
|
do
|
||||||
local env = setmetatable(createShellEnv("/rom/modules/internal"), { __index = _ENV })
|
local env = setmetatable(createShellEnv("/rom/programs"), { __index = _ENV })
|
||||||
require = env.require
|
require = env.require
|
||||||
end
|
end
|
||||||
local expect = require("cc.expect").expect
|
local expect = require("cc.expect").expect
|
||||||
@ -655,7 +655,7 @@ else
|
|||||||
term.setCursorBlink(false)
|
term.setCursorBlink(false)
|
||||||
|
|
||||||
-- Run the import script with the provided files
|
-- Run the import script with the provided files
|
||||||
local ok, err = require("cc.import")(event[2].getFiles())
|
local ok, err = require("cc.internal.import")(event[2].getFiles())
|
||||||
if not ok and err then printError(err) end
|
if not ok and err then printError(err) end
|
||||||
|
|
||||||
-- And attempt to restore the prompt.
|
-- And attempt to restore the prompt.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user