1local function
move(src_in, dist_path, dist_file)
3 local pattern =
"local ([%w_%-]+) = require%('src/(.-)'%)"
4 local src_file = io.open(src_in,
"r")
5 local dist_file_normalized = src_in:gsub(
'/',
'_'):gsub(
'^src_',
'')
6 local dist_out = dist_path:gsub(
'/$',
'')..
'/'..(dist_file or dist_file_normalized)
7 local dist_file = io.open(dist_out,
"w")
9 if src_file and dist_file then
11 local
line = src_file:read()
13 local line_require = {
line:match(pattern) }
14 if line_require and #line_require > 0 then
15 local var_name = line_require[1]
16 local module_path = line_require[2]
17 deps[#deps + 1] =
'src/'..module_path..
'.lua'
18 dist_file:write(
'local '..var_name..
' = require(\''..module_path:gsub(
'/',
'_')..
'\')\n
')
20 dist_file:write(line, '\n
')
36local function build(src_in, dist_path)
39 local deps_builded = {}
42 if src_in:sub(-4) == '.lua
' then
44 local index_deps = #deps
45 local file_name = main and 'main.lua
'
46 local new_deps = move(src_in, dist_path, file_name)
47 while index <= #new_deps do
48 deps[index_deps + index] = new_deps[index]
56 while index <= #deps and not src_in do
57 local dep = deps[index]
58 if not deps_builded[dep] then
59 deps_builded[dep] = true
local function move(src_in, dist_path, dist_file)
local function line(x1, y1, x2, y2)